首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sinch VoIP ManagedPush通知无效(Swift)

Sinch VoIP ManagedPush通知无效(Swift)
EN

Stack Overflow用户
提问于 2016-06-04 21:22:45
回答 1查看 1.4K关注 0票数 2

我一直在尝试实现VoIP ManagedPush通知,但是它们不起作用。以下是我为实现ManagedPush所采取的步骤:

1)在Apple中创建了一个VoIP服务证书。将证书的.p12文件上载到Sinch。

2)实例化sinchClient和push客户机var sinchClient: SINClient!; var push: SINManagedPush!

3)在didFinishLaunchingWithOptions函数中初始化push客户端和sinch客户端:

代码语言:javascript
复制
    // 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)初始化sinchClient。当用户通过facebook登录时被调用。

代码语言:javascript
复制
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)在函数didRegisterForRemoteNotificationsWithDeviceToken中,我放置了以下代码行:

代码语言:javascript
复制
self.push.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)

6)在函数didRecieveRemoteNotification中,我放置了以下代码行:

代码语言:javascript
复制
self.push.application(application, didReceiveRemoteNotification: userInfo)

7)为SINManagedPushDelegate创建委托函数

代码语言:javascript
复制
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)
     }     
}

因此,我的问题真的归结为我做错了什么,ManagedPush没有工作。我读过SinchCallingPush,并对其进行了转换,并试图完全按照代码执行,但它仍然不起作用。我认为这可能与不实现PushKit有关。如果是这样的话,请有人指出如何正确地导入它以及在哪里使用它。

我也在https://stackoverflow.com/questions/37577566/instant-message-push-notification-using-sinch-not-coming-on-ios看过一个类似的问题

EN

回答 1

Stack Overflow用户

发布于 2016-06-04 21:48:49

出了点事就开始起作用了。现在,我收到了一个错误,上面写着SIN_INCOMING_CALL。我相信我可以搜索并解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37635146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档