Configure Mobile App For Push
In order for Growlytics to handle push notifications, following configuration/changes needs to be done in your mobile app:
Step 1: Add/Configure App Target
Turn ON App Groups in for your app target and enable one of the App group ids, in case if you don't have an App Group ID then create one. The name of your app group should be group.{your_bundle_id}.Growlytics.
Turn ON Background mode and set/enable Remote Notification.
Turn ON the Push Notifications capability for your app.
Step2: Add UserNotifications framework
In the App's Target add UserNotifications framework in Linked Frameworks and Libraries and set it to Do not embed.
Step2: Registering for Push notification
Make sure that class, where UserNotificationCenter delegate methods are implemented, should agree to UNUserNotificationCenterDelegate , also set the UNUserNotificationCenterDelegate after the app launch in application:DidFinishLaunchingWithOptions:
as shown below.
Step3: Configure AppDelegate swizzling in SDK
In Growlytics SDK we have swizzled the AppDelegate Class to get all the callbacks related to Push Notifications and also we have applied method swizzling for UserNotificationCenter delegate methods.
In case you prefer not to use swizzling, you can disable the same by adding the flag GROWLYTICS_SWIZZLING
in the app’s Info.plist file and setting it to bool value NO.
Below are the callbacks the app would receive on receiving the push notifications. In case you have disabled swizzling, include calls to Growlytics SDK methods on receiving notification callbacks as shown below:
Step 4: Report Push Token to Growlytics
When you ask for push permission and push permission is approved, an push token is generated and returned by iOS. This push token will be used by Growlytics to send notifications from Growlytics dashboard. To report generated push notification to Growlytics, you can use setPushToken
method of GrowlyticsMessagingService
class as shown in code snippet below.
Step 5: Configure Notification Service Extension
Notifications have got a complete revamp after the release of iOS10 with the introduction of new UserNotifications and UserNotificationsUI framework. And with this we got Notification Service App Extensions, which can be used for following:
Add media support in Notifications: Post iOS10 Apple has given us the ability to add image files to the notifications and this can be done using the Notification Service Extension.
For Tracking Notification Impression: We can track if a Notification is received by the device using the Notification Service Extension.
Follow the below steps to set up Notification Service Extension:
Create a Notification Service Extension Target:
Set the name of the extension target and the programing language which you want to use:
After the target is created, Activate the scheme for Extension when prompted for the same. After this, your extension will be added to the project you will see a class with the extension name provided by you while creating and .plist file associated with it.
Then make sure that the Push Notifications Capability is enabled for the Notification Service Extension created:
Next, you will need to add "UserNotifications.framework" to the extention target that we created. Add UserNotifications framework to Linked Frameworks and Libraries of notification service extension target as shown below:
In the new class created by notification service extension, do the following changes
Last updated