In this blog post we review the process of setting up and developing an iOS application capable to receive Apple Push Notifications. We also review the functionality of publishing a push notification through Backendless.
Creating App ID
First we are going to create an App ID for the application which will receive Push Notifications. Login to Apple Developer Member Center. Click on “App IDs” in the “Identifiers” section. Use the plus sign “+” button to create a new ID:
When prompted enter App ID Prefix. Make sure it is descriptive enough so you recognize it later when you return to the Member Center.
Select Explicit App ID in the “App ID Suffix” section and enter the same bundle ID which you will be using in the application:
In App Services select the services which the application will use and click “continue”:
Make sure that Push Notifications are enabled and click “submit”. This will conclude the App ID creation for the app:
Creating Certificate Request
Push Notifications require a certificate which will be used on a device by the means of a provisioning profile. Also the same certificate (transformed to the Personal Information Exchange – .p12 format) will be used by Backendless to publish Push Notifications. If this makes little sense, do not worry, you will need to perform these steps only ones and then can move on to code and using the APIs.
In order to create a certificate a Certificate Signing Request (CSR) must be issued. To create a CSR, open Keychain Access and select Keychain Access >> Certificate Assistant >> Request a Certificate from the main menu:
Enter your email address and Common Name (leave the CA Email Address field empty), select “Saved to disk” and click “Continue”:
Select a directory where to save the file and click Save.
Generating an SSL Certificate for Push Notifications
The CSR file created in the section above will be used to create an SSL Certificate. That certificate will then be used by Backendless to publish push notifications.
Select certificate type – there are two options Development and Production. For now select “Apple Push Notification service SSL (Sandbox)”:
Select the App ID created earlier in these instructions:
Next you will see the instructions for generating a CSR which you have already created by now. Click Continue to proceed to the next step.
Select the CSR file created and saved to the disk earlier and click Generate:
The certificate is ready now, click “Download” to download it:
Add the certificate file to Keychain Access.
Open Keychain Access and locate the certificate in the “My Certificates” section:
Right click on the certificate and select the Export option:
Save the certificate in the p12 format:
Enter a password for the certificate. Make sure to make a record of the password – you will need to use it later in the instructions when you submit the certificate to Backendless:
Enter your Mac OS X account password to confirm the action. At this point, you have a certificate for Push Notifications.
Configuring Backendless App with the Certificate
Since Backendless provides the actual server-side integration for delivering Push Notifications for your application, it needs to have access to the certificate you created above. The steps below provide the instructions for uploading the certificate into Backendless:
Click Manage > App Settings. Locate the Mobile Settings section and upload the .p12 certificate created earlier. Make sure to enter the same password you used when created the certificate:
Now your Backendless server is ready to publish Push Notifications.
Creating Provisioning Profile
Login to Apple Developer Member Center and select “All” under Provisioning Profiles. Click the plus button “+” to create a new profile:
Select the “iOS App Development” profile type:
Click Continue. On the next screen select the App ID which was created earlier:
Click Continue. Select the users/certificates which will be included into the profile.
Click Continue. Select the devices to include into the profile.
Click Continue. Enter a name to assign to the profile and click Generate:
Download the profile:
Start XCode and open Organizer. Select the Provisioning Profiles section and add the profile you generated/downloaded:
Creating App in XCode
Finally, all the setup is done and we can proceed to the fun part – creating an app in XCode and writing some code.
Open XCode and create new “Single View Application”.
Enter “pushNotificationSample” as the Product Name. Also, provide your organization name and company identifier. Since the bundle ID we used when creating App ID earlier was “com.backendless.pushNotificationSample”, you should use “com.backendless” as the “Company Identifier”:
Once the application is created, open Targets > Build Settings > Code Signing > Code Signing Identity and select the provisioning profile created earlier:
At this point, you should add Backendless SDK to your project. This includes adding the Backendless library and its dependencies. Additionally, you will need to copy/paste Backendless Application ID and Secret Key into the code. For detailed instructions on how to do that, please follow the Backendless Quick Start Guide for iOS.
Open AppDeletage.m. The following code registers the device with Backendless and Apple Push Notification Service:
In case of the successful registration, the device is ready to accept published Push Notifications. When a notification is delivered to a device, the following method is invoked when the app is running.
Click Publish. The Push Notification will be delivered to all registered iOS devices:
To see a list of the registered devices use the Devices tab. You can also send a push notification to specific devices. In order to do that, select the devices using the checkboxes and then click the “Selected devices” option under “Push Notification” section:
The Landing Pages feature is going away and being replaced by page templates in UI Builder. Read on to learn more about this change, and why it makes our Landing Pages much more versatile! Back in July of 2018, we introduced the Landing Pages feature in version 5.1.0. This was a full 2 years before the…
[vc_row][vc_column][vc_column_text] Thunkable is a no-code app builder specializing in iOS and Android mobile apps. When you integrate a feature-rich no-code Backendless backend with your Thunkable app, you get a visual relational database, user management, bulletproof security, highly-scalable serverless hosting, and much more. Building a mobile or web app used to be an enormous undertaking. Creating apps, or digital…
We've made it easier to manage all of your apps from one place. With our latest release, you can view and manage all of your apps' billing information in one place. To access your account info, click the profile icon in the top-right corner of Backendless Console. There, click on My Account and you will…