Skip to main content
Major Release (V 1.0.0) 🚧Starting from iOS version v1.0.0, we have introduced explicit push notification permission and option to add images in your notification. Also, introduced background mode for improved tracking of notification delivery.If you are using an iOS version older than v1.0.0 and upgrading to the new version. Please ensure to use the latest integration steps, especially for below methods:
  1. Adding Background mode capability (point 3 of capabilities)
  2. Calling registerPush method
  3. Tracking delivery methods
1

Add capabilities in iOS application

  1. Inside Targets select signing and capabilities
  2. Click on +capabilities and select Push Notifications and Background Modes
In Background Modes, select Remote Notifications option. We use background notifications to receive delivery reports when your app is in quit and background state. Refer doc to know more about background notification
2

Register for push notifications

Call registerForPushNotifications method below the SuprSend SDK initialised code which will register the iOS device for push service.If you have AppDelegate.m file then make follow code changes given in AppDelegate.h and AppDelegate.m file. If you have AppDelegate.swift file then make follow code changes given in AppDelegate.swift file.
3

Asking User to send push notifications

There are 2 ways in which your app can prompt the users to allow push notifications on their device:
Explicit authorization allows you to display alerts, add a badge to the app icon, or play sounds whenever a notification is delivered. In this type of authorization, the request is made the first time user launches your app. If the user denies the request, you can’t send subsequent prompts to send the notification.
Explicit authorization is our default authorization method as it automatically sets alert, sound and badge as soon as the user allows this request.
Provisional notifications are sent quietly to the users -they don’t interrupt the user with a sound or banner. Also, they will not be shown when your app is in foreground. First time this type of notifications are sent, user is asked to “Keep” or “Turn off” the notifications. If they click on “Keep”, the further notifications continue to be sent
Add below code in AppDelegate file for provisional authorization.
4

Enable sending and tracking of push notifications

To enable sending iOS APNS token to SuprSend backend, delivery and tracking of push notification delivery/clicks/dismiss events, add below 4 methods in AppDelegate file after last existing method.
iOS Push notifications only work on real devices so while developing/testing use real device to test it instead of simulators
5

Adding support for Notification service

For better notification status (delivered, seen) tracking this step is needed.
  1. In Xcode go to File > New > Target.
  2. Select Notification Service Extension from the template list.
  3. Then in Next popup give it any product name, select your team, select swift language and click finish.
After clicking on “Finish”, a folder will be created with your given product name. Inside that there will be NotificationService.swift file like below.
In your project podFile add following snippet at the end of existing code like shown in image. Replace <your notification service name> with name you given to notification service while creating it. After that Run pod install.
Replace the content in NotificationService.swift file with below code. In this snippet on line 11, 12 replace values with your workspace key and workspace secret.
You are now all set to send push notifications. All you have to do is add iOS vendor configuration on SuprSend dashboard and your push notifications will be configured. Please refer vendor integration guide to integrate your apns push service