Push Notification
Push Notification Setup
Add import statement in AppDelegate file to access the methods
a) Send device token to Kommunicate server:
In your AppDelegate’s didRegisterForRemoteNotificationsWithDeviceToken method send device token registration to Kommunicate server after you get deviceToken from APNS. Sample code is as below:
b) Receiving push notification:
Once your app receives notification, pass it to Kommunicate handler for chat notification processing.
Add the following code in AppDelegate class, this function will be called after the app launch to register for push notifications.
c) Handling app launch on notification click:
Add the following code anywhere inside the AppDelegate class, refer to this sample for the better understanding.
d) AppDelegate changes for foreground notification:
The following functions will be called by AppDelegate when the app comes to foreground(active) mode, add this anywhere inside the AppDelegate class.
An optional step that is only required if you want to reset the app icon badge count after a user opens the app.
e) Save Context when app terminates:
You can check the sample AppDelegate file here.
Certificates
a) Upload development and distribution APNs certificates
Upload development and distribution APNs certificates on Kommunicate dashboard, this will allow Kommunicate to send the notification for new messages to your mobile app.
b) Updating Capabilities
Post setting up APNs, the next step is to enable “Push Notifications” and “Background Modes” within your project.
Click on your project, select it from TARGETS.
Next select ‘Signing & Capabilities’ section.
Click on “+Capability”
Search and select “Push Notifications”
Click on “+Capability” again
Search and select “Background Modes”
Enable “Background Fetch” and “Remote notifications” under “Background Modes” list
Following screenshot would be of help.
Last updated