Add import statement in AppDelegate file to access the methods
import Kommunicate
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:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
print("DEVICE_TOKEN_DATA :: \(deviceToken.description)")
var deviceTokenString: String = ""
for i in 0..count
{
deviceTokenString += String(format: "%02.2hhx", deviceToken[i] as CVarArg)
}
print("DEVICE_TOKEN_STRING :: \(deviceTokenString)")
if (KMUserDefaultHandler.getApnDeviceToken() != deviceTokenString)
{
let kmRegisterUserClientService: KMRegisterUserClientService = KMRegisterUserClientService()
kmRegisterUserClientService.updateApnDeviceToken(withCompletion: deviceTokenString, withCompletion: { (response, error) in
print ("REGISTRATION_RESPONSE :: \(String(describing: response))")
})
}
}
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.