【问题标题】:Sendbird not pushing notifications on iOSSendbird 没有在 iOS 上推送通知
【发布时间】:2019-08-29 17:01:55
【问题描述】:

我已关注文档并已成功注册了 Sendbird 的推送通知(已上传 .p12 开发证书 + 使用 Sendbird SDK 注册设备令牌等),但没有收到任何通知。

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

    NSUserDefaults.standardUserDefaults().setObject(deviceToken, forKey: "deviceToken")

    SBDMain.registerDevicePushToken(deviceToken) { (status, error) in
        if error == nil {
            if status == SBDPushTokenRegistrationStatus.Pending {

                SBDMain.connectWithUserId("\(UserDataStore.ownerProfile?.id!)", completionHandler: { (user, error) in

                    SBDMain.registerDevicePushToken(SBDMain.getPendingPushToken()!, completionHandler: { (status, error) in
                        print("Sendbird Registration Succeeded 2nd attempt")
                    })
                })

            } else {
                print("Sendbird Registration Succeeded")
            }
        } else {
            print("Sendbird Push Registration Failed")
        }
    }
}

在我的 didReceive...我什么也没得到。

 func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    if let aps = userInfo["aps"] as? NSDictionary {
        if let alert = aps["alert"] as? NSDictionary {
            if let message = alert["message"] as? NSString {
                print(message)
            }
        } else if let alert = aps["alert"] as? NSString {
            print(alert)
        }
    }

    if application.applicationState ==  .Inactive {
        NSNotificationCenter.defaultCenter().postNotificationName("pushNotificationReceived", object: nil)
    } else {
    NSNotificationCenter.defaultCenter().postNotificationName("pushNotificationReceivedActive", object: nil)
    } 
}

我过去做过推送通知,并且熟悉这个过程。事实上,我刚刚使用 Firebase Cloud Messaging 进行了测试,并且推送在他们的服务中运行良好。如果有人可以提供帮助,将不胜感激...我很想知道 Sendbird 是否需要采取任何其他步骤。

更新:我已经联系了 Sendbird,问题是您上传 .p12 文件的仪表板上的错误;删除文件并重新上传可以解决问题。该错误已被修复。

【问题讨论】:

    标签: ios swift apple-push-notifications sendbird


    【解决方案1】:

    SendBird 仅在用户离线时向用户发送推送通知。

    请确认您已向离线用户发送消息。 (例如,按下主页按钮使应用程序在后台运行,使其从 SendBird 变为离线)

    【讨论】:

    • 对我来说,沙鸟的推送通知仅在应用程序处于后台时才会出现。但它没有击中应用程序委托中的 didReceiveRemoteNotification 函数。实际上它在显示通知时没有触发任何功能
    【解决方案2】:

    对于那些在应用程序运行时未收到推送通知并且仅在用户离线时收到推送通知的用户,您必须在用户连接后为通道注册回调处理程序以通过通道接收消息委托,然后您可以从那里发出本地推送通知:

    class GroupChannelChattingViewController: UIViewController, SBDChannelDelegate {
        SBDMain.add(self as SBDChannelDelegate, identifier: self.delegateIdentifier)
    
        func channel(_ sender: SBDBaseChannel, didReceive message: SBDBaseMessage) {
            if message is SBDUserMessage {
                // Do something when the received message is a UserMessage.
            }
            else if message is SBDFileMessage {
                // Do something when the received message is a FileMessage.
            }
            else if message is SBDAdminMessage {
                // Do something when the received message is an AdminMessage.
            }
        }
    }
    

    这可以在here找到。

    【讨论】:

      猜你喜欢
      • 2018-06-16
      • 2019-02-16
      • 1970-01-01
      • 1970-01-01
      • 2013-01-26
      • 2015-01-14
      • 1970-01-01
      • 2018-12-20
      相关资源
      最近更新 更多