We use APNS services to receive messages in background.
In your Appdelegate, register for remote notification by conforming to the delegates
Call the below methods when an APNS token gets updated.
To receive push notification in the background or in the killed state, You need to enable below capabilities.
Now, go to the background mode and enable the below given modes
To receive messages in the background or in the killed state, You need to enable app group container ID.
In order to access data between app and notification extension, enabling app group is mandatory to access user defaults and database in container.
We have to set
In function didFinishLaunchingWithOptions use this
ChatManager.setAppGroupContainerId(id: CONTAINER_ID) method to set CONTAINER_ID which is your
App Group string name
|CONTAINER_ID||Create App groups and assign the obtained group container id. SDK uses this string to create the path for the local storage.|
Changing existing app group container may cause data loss.
As a process of getting push notification in background and Killed state, the SDK require to add
Notification Extension service in your Xcode project.
Notification service extension can be acts as a mediator between the User Interface and the APNS. Like all other iOS extensions, such an extension can simply be added to the app in the form of another target.
Create NotificationExtension Target
You can see New target and NotificationService folder been created in your project.
MirrorflySDK to the new target created for NotificationExtension in
Do Pod install
Start using the SDK using the below statement
Re-initialize the ChatSDK method and setAppGroupContainerId method inside func
didReceive method of the
In class that extends the
UNNotificationServiceExtension call the above
NotificationMessageSupport.shared.didReceiveNotificationRequest method to process the request further.
|NOTIFICATION_CONTENT||Notification request content|