From i2CSMobile v1.3 and later we use OneSignal as push notification service provider. First of all visit onesignal.com and register for a new account or login with existing login. Once you are logged in, create a new app for your push notification services. Please refer this for more info.
- Open ionic app www/app/variables.js file
- Find the constant values for ONESIGNAL_APP_ID and GCM_SENDER_ID
- You can get the onesignal app id from App Settings item in the onesignal.com dashboard
4. To obtain GCM SENDER id, refer to 3.1 step of next section
Generate a Google Server API Key
This is a part of the onesignal documentation. Here is the full version
Your Google Server API Key and Google Project Number are used to send push notifications to ANDROID devices.
To begin, we’ll obtain a Google Server API Key and Google Project Number. These keys allow OneSignal to use Google’s web push services for your notifications.
1. Create a Google app
1.1 Visit the Google Services Wizard.
1.2 Type any name to create a new app, or select an existing Google app from the dropdown.
In this example, we create an app named
1.3 We do not use the Android package name, but you must enter a value to continue. Please use the value
test.test as shown below.
1.4 Click Choose and configure services to continue.
Wait a minute for the project to be created.
2. Enable Google Cloud Messaging
2.1 Click Enable Google Cloud Messaging.
3. Get your Google keys
3.1 Save the two values listed:
- You’ll need your Server API Key later in our SDK Installation guide
- You’ll need your Sender ID, also known as the Project Number, later as well
SENDER ID / PROJECT NUMBER
The Sender ID is also known as the Project Number. You’ll need this later in the SDK installation guide.
Google Server API Key
You’ll need your Google Server API Key later on the SDK Installation guide.
4. Configure your OneSignal app’s Android platform settings
4.1 Go to App Settings and press the Configure button to the right of Google Android.
4.2 Paste your Google API Key in here and press Save.
Generate an iOS Push Certificate
The goals of this section are to provision your app with Apple and grant OneSignal access to manage your notifications.
Learn more: What are iOS Push Certificates?
The Apple Push Notification Service (APNs) is a service created by Apple Inc. way back in 2009 to securely send push notifications from third party apps to their users’ Apple devices.
Your backend sends notifications through Apple’s servers to your application. To ensure that unwanted parties are not sending notifications to your application, Apple needs to know that only your servers can connect with theirs.
Apple therefore requires you to create an SSL certificate. Although app provisioning can be confusing at times, follow along and it should only take a couple minutes.
Option A: Try out our Automatic Provisioning Tool
We recently released a tool to automate this process!
— OR —
Option B: Create Certificate Request Manually
1.1 Open Keychain Access on your Mac OS X system. It may be located in “Applications” > “Utilities” > “Keychain Access”
1.2 Select “Keychain Access”>”Certificate Assistant”>”Request a Certificate From a Certificate Authority…”
1.3 Select the “Save to disk” option and enter your information in the required fields. This creates a certification request file that will be used later.
2. Enable Push Notifications and apply the Certification Request to generate Certificate
2.1 Select your app from the Apple’s Developer site and press “Edit”
2.2 Scroll down to the bottom and enable Push Notifications. Press Done, but do not configure either Production or Development certificate.
Instead, go to Create new certificate page and select “Apple Push Notification service SSL (Sandbox & Production)” and click Continue.
This certificate will be applicable to both Sandbox and Production environments, so you do not need a separate key for each one.
2.3 Choose an App ID from the App ID pop-up menu, and click Continue.
2.4 Press Continue
2.5 Press “Choose File..”, select the “certSigningRequest” file you saved in step 1, press open, and then press “Generate”.
2.6 Press Download to save your certificate
3. Creating a Private Key
3.1 Open the .cer file you downloaded in the last step by double clicking on it in Finder.
3.2 After a few seconds the “Keychain Access” program should pop up. Select Login > Keys then right click on your key in the list and select “Export”
3.3 Give the file a unique name and press save. You will have an option to protect the file with a password. If you add a password, you need to enter this same password on OneSignal.
4. Upload Your Push Certificate to OneSignal
4.1 From OneSignal, go to “App Settings” and press Configure to the right of the Apple iOS Settings.
4.2 Select the .p12 you exported along with a password if you added one and press Save.
You must make sure
Push Notifications are enabled on your provisioning profiles before building your app! Please fully follow Step 5 below or your users will NOT be subscribed.
5. Provisioning Profiles
5.1 On the left to go to All > Provisioning Profiles. Next find any that are for your app and delete them if they do not have
Push Notifications in
5.2 Recreate the ones you need by pressing the “+” button on the upper right.
5.3 When recreating new ones make sure to enter a unique name in the “Profile Name:” field.
Example, here we created an Ad-Hoc Provisioning Profile so we can test push notifications with our Production Push Certificate .p12 file. We used the format AppName_AdHoc so we know the app and type it is.
5.4 Re-sync your Developer Account in Xcode by going to Xcode > Preferences… then click on the “View Details…” button. Lastly, click the refresh button on the bottom left of the popup. See Apple’s documentation for more detailed instructions.
5.5 Make sure you pick your new provisioning profile from Build Settings>Code Signing>Provisioning Profile in Xcode.
Notifications are working on real devices only. If you have successfully followed above steps and install the app on a physical device, you should be able to see new users are registered in users section on the OneSignal app. For further reading of sending push notifications and managing users, refer this tutorial