0

[![enter image description here][1]][1]I've mentioned all the fields but still I'm not getting the push notification. This is my code:

Firstly in didFinishLaunchingWithOptions I call this:

        self.push = Sinch.managedPushWithAPSEnvironment(.Production)
        self.push?.delegate = self
        self.push?.setDesiredPushTypeAutomatically()

        client = Sinch.clientWithApplicationKey("xxxxxx", applicationSecret: "xxxxxxx", environmentHost: "sandbox.sinch.com", userId: userID)
        client?.delegate = self
        client?.setSupportMessaging(true)
        client?.setSupportPushNotifications(true)
        client?.enableManagedPushNotifications()
        client?.start()
        client?.startListeningOnActiveConnection()

        self.push?.registerUserNotificationSettings()

func managedPush(managedPush: SINManagedPush!, didReceiveIncomingPushWithPayload payload: [NSObject : AnyObject]!, forType pushType: String!) {

        self.client?.relayRemotePushNotification(payload)
    }


func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

        let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
        var tokenString = ""

        for i in 0..<deviceToken.length {
            tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
        }

        self.push?.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
    }


func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
        self.push?.application(application, didReceiveRemoteNotification: userInfo)
    }

I've also uploaded the push certificate in my sinch dashboard.

May I know what am I missing in this code that might be the reason I'm not getting push.

EDITED:

Here is the image of the uploaded push distribution certificate on Sinch Dashboard.

https://i.stack.imgur.com/d6PVb.png

Bhavuk Jain
  • 2,167
  • 1
  • 15
  • 23

1 Answers1

0

You should not have client?.setSupportPushNotifications(true) thats for when you want to handle the push your self

cjensen
  • 2,703
  • 1
  • 16
  • 15
  • So for managed push it will use VoiP push automaticly, have you uploaded that to the dashboard? func managedPush(managedPush: SINManagedPush!, didReceiveIncomingPushWithPayload payload: [NSObject : AnyObject]!, forType pushType: String!) { self.client?.relayRemotePushNotification(payload) } Should not be necessary either. – cjensen Jun 01 '16 at 21:51
  • I'm not using voip. I just want a normal remote notification. I've uploaded the push certificate for distribution and it shows as default in sinch dashboard. – Bhavuk Jain Jun 01 '16 at 22:31
  • I tried with a development certificate and it works fine. But when I try with a distribution push certificate it doesn't work. The same distribution push certificate works fine on my backend but not with Sinch. – Bhavuk Jain Jun 02 '16 at 09:45
  • is your issue fixed, can someone help me I will really appreciate – Meet Ios Developer Jun 21 '20 at 18:25