Push Notifications in AppStore Apps
AppStore Apps are MobileTogether apps that are compiled into different OS-based apps. These apps can be posted to the respective app stores for end users to download. (See the section AppStore Apps for details.) In order to compile the program code for the different operating systems, you must first generate the program code for the respective operating systems. This is done with the help of the Generate Program Code Wizard. If your MobileTogether app of the receiving solution is set to receive push notifications (PNs), then you must fill in the relevant settings in the Wizard's Screen 6. (Note that this screen appears only if the OnPushNotificationReceived event of the solution has an action defined for it.)
Using PNs in AppStore Apps entails some additional steps, which are explained below. You will need to carry out these steps before generating the program code; that's because the registration information you will obtain after carrying out these steps is required in order to complete the settings in Screen 6 of the Generate Program Code Wizard.
|Note:||The steps to prepare an app to receive push notifications apply only to the apps of receiving solutions. If the apps for the sending and receiving solutions are different apps, then the steps outlined in this section apply only to the app of the receiving solution; they do not apply to the app of the sending solution.|
Android and iOS
In order for your Android and iOS apps to receive PNs, you must have a Firebase account and have created a Firebase Server key.
Note down the Firebase Server key for use in Screen 6 of the Generate Program Code Wizard.
Create your Android app in the Firebase Console. Go to the app's page and download its google-services.json file.
Note the location of the downloaded google-services.json file. Do not change the name of the file. You will need to point to this file in Screen 6 of the Generate Program Code Wizard.
You will need to: (i) generate an Apple Push Notification service (APNs) key, and (ii) do some configuration in Firebase, and generate and download a GoogleService-Info.plist file. To do these, carry out the steps listed below.
Generate an APNs key (needed only one per Apple developer account; can be used across various projects):
1.Create an APNs key at https://developer.apple.com. Do this as follows: Under Account > Certificates, ID & Profiles > Keys, click the Add button (+), and create the key.
2.Confirm and download the APNs key file, which has a .p8 extension and is generated once only. Store the key file at a secure location. Also store the 10-digit authentication key ID. The key file and the authentication ID are needed only once, to set up for your Apple Developer Account.
Configure Firebase, and generate and download a GoogleService-Info.plist file:
1.Create your iOS app in your Firebase Console.
2.Upload the .p8 file that you generated earlier.
3.Specify app id prefix—not bundle ID prefix—as well as the 10-digit authentication key id (obtained during APNs key generation).
4.Download the GoogleService-Info.plist file.
Note the location of the downloaded file. Do not change the name of the file. You will need to point to this file in Screen 6 of the Generate Program Code Wizard.
Q: What might be the problem if push notifications are not received on the phone?
A: One or more of the following issues might be responsible:
•After the AppStore App has been installed, it must be started at least once. When asked if receiving PNs should be allowed, click Yes. After the app starts and contacts the server, the client's PN address is sent to the server.
•If you can receive broadcast messages for a specific topic but not for a compiled app, then check that the solution name to which the PN is sent is correct.
•Check that the p8 file and the two keys (APNs and authentication key) have been uploaded.
•Check that the Bundle ID in the Firebase settings and in the generated AppStore App are identical.
•Check that PNs for your app ID in Apple's Developer Console have been enabled.
•If none of the above apply, go to xcode/your project/capabilities. Switch off the PN switch, and then switch it on again.
Q: "Show as notification" does not work on iOS 9.
A: This is not an error. Support is provided for iOS 10 or later.
When generating program code for a Windows app of a PN-receiving solution, you will need, for Screen 6 of the Generate Program Code Wizard, two pieces of information: (i) the Package SID, and (ii) the Application Secret. The procedure to obtain these is as follows:
1.Login at https://developer.microsoft.com/en-us/dashboard with your user name and password.
2.If the app does not yet exist in the store, you can proceed with the steps that follow after reserving a name for the app.
3.Go to your app’s page, and there select Services > Push notifications > WNS/MPNS; in some cases, the WNS/MPNS item is listed under App management (see screenshot below).
4.In the page that appears, click Live Services site (boxed in red in the screenshot above).
5.The Registration page of the app will open. Note down the following details from this page; you will need them to generate the program code with the Generate Program Code Wizard: (i) Package SID, (ii) Application Secrets. Click Save to finish the procedure.
6.You can now start the Generate Program Code Wizard to create the program code.