Difference between revisions of "Setup Push notifications for iOS or Android"

From Sky Networks Wiki
Jump to navigation Jump to search
Line 8: Line 8:
  
 
2. mod_sofia configuration:  It is configured as follows:
 
2. mod_sofia configuration:  It is configured as follows:
 +
 +
The SkyDANCE SkyPhone for iOS and Android is already setup to use push messaging. 
 +
 +
However if you want to incorporate your own solutions
  
 
Click here for instructions on how to setup firebase cloud messaging on your app.
 
Click here for instructions on how to setup firebase cloud messaging on your app.

Revision as of 08:30, 1 August 2019

Click Here to return to the the SkyPhone Main Screen: Back

Push notifications are used to notify the user of incoming calls and start SkyPhone when it is not running. If Skyphone is running, it will simply receive the call and start ringing.

To setup push notifications requires 2 things:

1. An updated mod_sofia.so module which you can obtain from Sky Networks.

2. mod_sofia configuration: It is configured as follows:

The SkyDANCE SkyPhone for iOS and Android is already setup to use push messaging.

However if you want to incorporate your own solutions

Click here for instructions on how to setup firebase cloud messaging on your app. https://firebase.google.com/docs/cloud-messaging


Click here for instructions on how to setup your push notification certificate for Apple. This is required for apple notifications even if you use firebase for the push instead of APN (Apple Push Notifications) https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns


Once it's setup you can access

a) For google firebase you will need your Legacy server key - which can be found under your project settings, cloud messaging tab.

b) For Apple you will need the push certificate from their developer console. This file should be put into he ios push certification is put into the /home/skynet/sky/bin/Certs folder There is a script (genpems) to convert the downloaded .p12 files into the required pem certificates. Edit the script as necessary to create production or dev certificates. The files that are needed for push are:

apns-dis-key.pem
apns-dis-cert.pem

or

apns-dev-key.pem
apns-dev-cert.pem

The configuration file is located in /home/skynet/sky/conf/autoload_configs/sofia.conf.xml

 <!-- push server -->
    <-- ios skyphone has a base64 encode. This variable is used to check that.-->
    <param name="is-ios-encode" value="1"/>
    <!--If there is base64 encode, set this value. But there is no base64 encode in Skyphone. -->
    <param name="is-android-encode" value="0"/>
    <!--Send push for calls where the phone is not registered (otherwise the push script needs to be put in the dialplan) -->
    <param name="is-push-every-call" value="1"/>
    <!--Use the Apple dev certificate or production certificate.  -->
    <param name="is-dev-cert" value="1"/>
    <!--push type. 1:notification, 2:data. Currently, we don't support mixture of notification and data. -->
    <param name="push-method" value="1"/>
    <!--IOS push use FCM or not. If not, will use APNS-->
    <param name="ios-push-use-fcm" value="0"/>
    <!--FCM push URI. Normally it would not change-->
    <param name="android-push-url" value="https://fcm.googleapis.com/fcm/send"/>
    <!--API key of the app when created on google developer console. Product settings, cloud messaging - Legacy server key-->
    <param name="android-api-key" value="AIzaSyCE5l74KKPbOyWMZ-l2raqtUaD6FY2X0Y8"/>
    <!--The log file for push notifies-->
    <param name="push-log-file" value="/home/skynet/sky/log/sky_push.log"/>
    <!--It will use the "fs_cli -x" to call the API command to check endpoint state. Set the path of the fs_cli/sky_cli-->
    <param name="fs-cli" value="/home/skynet/sky/bin/fs_cli"/>
    <!--If the destination is UNREGISTER or EXPIRED, it's the wait time before destination's phone returns REGISTER message. Otherwise, it's not used.-->
    <param name="invite-wait-time" value="10"/>
  


2. push server Usage.

  There should be a script called pushtest to try it in the sky/bin directory
 Here is the source:
  1. !/bin/bash
  2. Send a push notify to a client
  3. $1 - calling number
  4. $2 - called number

fsc "sofia_push external2 $1 $2

 skydance push is an API command. It has 3 argments. The usage is:
  sofia_push <profile_name> <calling_number> <called number>


  2.1 The push can be used in diaplan like:
   <action application="lua" data="/home/skynet/sky/scripts/sofia_push.lua external2 1001 1002"/>