2

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

Community
  • 1
  • 1
Bhavik P.
  • 905
  • 3
  • 10
  • 28

1 Answers1

0

Something happened and it started working. Now I am getting an error that says SIN_INCOMING_CALL. I am sure I can google and fix this up.

Bhavik P.
  • 905
  • 3
  • 10
  • 28
  • can you provide some more info on the error, SIN_Incoming call is a resourece you should add to yoru string file to show the the template for incoming calls – cjensen Jun 06 '16 at 16:52
  • Yes thats exactly what I did, I had to create a Localizable.Strings file and it is now working. Only issue I have left is sometimes I open up my app, then close it by double clicking on home button and swiping up. Now when I receive a phone call, I receive a local notification. When tapping on the local notification it starts my app however it doesn't go to the call screen. When I get a remote one everything works fine. Do you have any idea why this is? By the way I might create another question on this; just incase someone else gets stuck. – Bhavik P. Jun 06 '16 at 23:50
  • @BhavikP. Did you get an answer on your last question? Going through similar issues. – Guven Dec 15 '16 at 11:13
  • @BhavikP. Can you please tell us what you did? I have done exactly the same thing that you have done and have been checking all the documentation and searching on google for a long time, and I can't find anything. I would REALLY appreciate it if you could tell us exactly what you did. Please! Thank you so much! – Jaqueline Jan 11 '18 at 01:58
  • if i open the app and double click on home button and swipe up (means kill the app) till 2 or 3 minute i have receive the local notification and call screen open but after 5 min if i call on user number i only receive SIN_INCOMING_CALL notification but call screen not open auto Sinch Developer Support are just waste of time of client they wont help, i think we should change the Sinch Service and move to other plat form or maybe someone help to resolve this issue – Shakeel Ahmed Jul 03 '19 at 05:31
  • the same problem with me can someone help – Meet Ios Developer Jun 21 '20 at 18:15
  • @cjensen Facing issues in sinch background can you help – Meet Ios Developer Jun 21 '20 at 18:55