使用 Sinch 的即时消息推送通知不会在 iOS 上出现 [英] Instant Message Push Notification Using Sinch not coming on iOS

查看:22
本文介绍了使用 Sinch 的即时消息推送通知不会在 iOS 上出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[![在此处输入图片描述][1]][1]我已经提到了所有字段,但仍然没有收到推送通知.这是我的代码:

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

首先在 didFinishLaunchingWithOptions 中我称之为:

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)
    }

我还在我的 sinch 仪表板中上传了推送证书.

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.

这是在 Sinch Dashboard 上上传的推送分发证书的图像.

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

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

推荐答案

你不应该有客户端吗?.setSupportPushNotifications(true) 那是当你想自己处理推送时使用的

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

这篇关于使用 Sinch 的即时消息推送通知不会在 iOS 上出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆