I have been trying to implement VoIP ManagedPush notifications however they aren't working. The following are the steps I have taken to implement ManagedPush:
1) Created a VoIP Services Certificate in Apple Developer. Uploaded a .p12 file of the certificate to the Sinch Dashboard.
2) Instantiated the sinchClient and the push client var sinchClient: SINClient!; var push: SINManagedPush!
3) Initialized the push client and sinch client in didFinishLaunchingWithOptions
function:
// Register for Sinch Notifications (for calling)
self.push = Sinch.managedPushWithAPSEnvironment(.Development)
self.push.delegate = self
self.push.setDesiredPushTypeAutomatically()
// Sinch
NSNotificationCenter.defaultCenter().addObserverForName("UserDidLoginNotification", object: nil, queue: nil, usingBlock: {(note: NSNotification) -> Void in
self.initializeSinch(note.userInfo!["userId"] as! String)
})
4) Initialized sinchClient
. called when a user is logged in via facebook.
func initializeSinch(loginId: String){
sinchClient = Sinch.clientWithApplicationKey("key", applicationSecret: "secret", environmentHost: "sandbox.sinch.com", userId: loginId)
sinchClient.callClient().delegate = self
sinchClient.setSupportCalling(true)
sinchClient.enableManagedPushNotifications()
sinchClient.start()
sinchClient.startListeningOnActiveConnection()
self.push.registerUserNotificationSettings()
}
5) In function didRegisterForRemoteNotificationsWithDeviceToken
I placed the following line of code:
self.push.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
6) In function didRecieveRemoteNotification
I placed the following line of code:
self.push.application(application, didReceiveRemoteNotification: userInfo)
7) Created the delegate function for SINManagedPushDelegate
:
extension AppDelegate: SINManagedPushDelegate{
func managedPush(managedPush: SINManagedPush!, didReceiveIncomingPushWithPayload payload: [NSObject : AnyObject]!, forType pushType: String!) {
self.handleRemoteNotification(payload)
print("HERE GOT A REMOTE NOTIFICATIOn")
}
func handleRemoteNotification(userInfo: [NSObject : AnyObject]) {
if (sinchClient == nil) {
let userManager = UserManager()
initializeSinch(String(userManager.user.facebookId))
}
self.sinchClient.relayRemotePushNotification(userInfo)
}
}
So my question really comes down to what am I doing wrong that the ManagedPush is not working. I have read SinchCallingPush and converted and tried to follow the code almost exactly yet it doesn't work. I think that maybe its something to do with not implementing PushKit. If this is the case could someone please point out how to correctly import it and where to use it?
I have also looked at a similar question at Instant Message Push Notification Using Sinch not coming on iOS