In order to send push notifications to your iOS apps, you need to generate .p12 certificates to use in the app.To create your certificates, you can follow this guide: https://github.com/
As long as your iOS device detects push, you don’t need an Apple developers account. There are 3 main steps to use Push.
-
App ID and SSL certification: This certificate allows the Parse server to send push notifications to the application identified by the App ID.
-
Provisioning profile for this app ID: It authenticates your device to run the app you are developing. Whether you have created a new App ID or modified an existing one, you will need to regenerate your provisioning profile and install it.
-
Configure Parse app using SSL certificate generated: To use Push Notifications with Parse, you will need to enable this feature in your Parse app and upload the Push SSL certificate you created above.
Let’s go through each of them in detail.
-
App ID and SSL certification
Before getting SSL certificate you need to sign a certificate signing request file. To get this done, you need to open your Keychain application. Go to keychain access and request a certificate from the certificate authority. Fill the required information and download the .cert signing request file.
Now, log in to the Apple developer portal. Go to iOS provisioning portal. Select App IDs from the menu.
If you have already configured an App ID for your app, double check that if was set up as an Explicit App ID. Wildcard App IDs do not support push notifications and are easy to identify: the last character in the bundle identifier is an asterisk (*). Wildcard App IDs cannot be converted to Explicit App IDs, but setting up a new App ID for your app is quite straightforward.
Select the new app ID button. Fill the form with all the details. Click on submit.
You will find your app ID in the list and there is an option to configure it. You will find the SSL certificate that you are looking for.
If you are still developing your app, you can pick Development Push SSL Certificate, and if you are ready to launch, then you can go for Production Push SSL Certificate.
In the next step, select the .cert file that we created earlier. Generate and download the SSL certificate.
Double click on the SSL certificate to install it. You will find this on your certificates’ list. You can right click on the Apple SSL certificate and save it as a P12 file.
Do not enter an export password when prompted! Leave both fields blank and click OK.
-
Provisioning profile for this app ID
Navigate back to the Apple development portal to the provisioning profile. You can use an existing App ID and existing provisioning profile. But you need to regenerate and reinstall it. If you want to create a new one, select new profile.
Fill in all the information and select your SSL certificate, app ID and the device you will be testing with. Submit to create the new profile.
Download the profile you created and double click on it to install it on your computer. The utility of your iPhone will prompt to add the new profile. Do that and close that app.
-
Configure Parse app using SSL certificate generated
To begin using Push feature, you need to inform Back4App about it. To do that, go to your app on the dashboard. Go to the settings tab. Under this, you have iOS Push notifications settings. Select your .p12 certificate that you generated. Click on development or production as per your requirement. If you want the app itself to initiate the push, then click on yes under Client push enabled.
Start by configuring your Xcode application’s project settings. We’ll need to make sure both the App ID and the provisioning profile are configured correctly.
Select your project in the Project Navigator, then select your application target in the main Editor window. Make sure “General” is selected at the top.
Modify the "Bundle Identifier" field under Identity to match your App ID’s Bundle Identifier (ex. com.example.MyParsePushApp). Xcode may warn you at this point if you have not configured your provisioning profile correctly.
Click on “Capabilities” and turn on Push Notifications. Again, Xcode will let you know if there are any issues that require your attention. Click on “Build Settings” and find the “Code Signing Identity” field. This field should be set to “iOS Developer” if you’re testing against development, or “iOS Distribution” if you’re testing in production or building your app for the App Store.
Make sure the provisioning certificate is configured correctly in your app. Once done, this is how you can configure Push Notifications.
Here are the changes you need to make in app delegate in order to receive push notifications.
Call the method registerForRemoteNotifications
If the registration is successful, the callback method application:
To notify about the Push, call the method storeDeviceToken on the PFPush object.
Next, subscribe the user to the broadcast channel using the method subscribeToChannelInBackground with an empty string.
If the device fails to register, you can call the method didFailToRegisterForRemoteNoti
But if it is running in the background, we can handle it using application didReceiveRemoteNotification. This helps to display modal notification content.
After this, build your application. Plug in your iOS device. Run it and close the display.
In your app, go to Push notifications tab. Send a sample message on the broadcast channel. Check this notification on your iOS phone.
Comments
0 comments
Please sign in to leave a comment.