Instant Message Push Notification Using Sinch not

2019-03-06 12:05发布

问题:

[![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.

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

回答1:

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