【问题标题】:iOS - PushKit without VOIP / FCM with CallKitiOS - 不带 VOIP 的 PushKit / 带 CallKit 的 FCM
【发布时间】:2018-01-06 18:46:44
【问题描述】:

我正在开发一个使用 CallKit 通知用户的应用程序。但是,我正在使用 APN 测试应用程序,但它没有按预期工作。

流程应该是: 接收 FCM -> 使用 Callkit 创建呼叫 -> 用户接受呼叫 -> 做某事。

流程与 WHATSAPP 之类的应用类似,但我没有 VOIP,我只需要确保每次有 FCM 时都激活 CALLKIT。

但是,目前,如果应用程序处于后台或非活动状态,则 callkit 将不会启动。

我正在考虑使用 PushKit 来实现它。但是,我没有使用 PushKit 的经验(不确定我的应用是否会被禁止,根据这篇文章:PushKit: Can we use push kit(VoiP Push) in Chat Application without using VoiP

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                 fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    // If you are receiving a notification message while your app is in the background,
    // this callback will not be fired till the user taps on the notification launching the application.
    // TODO: Handle data of notification
    // With swizzling disabled you must let Messaging know about the message, for Analytics
    // Messaging.messaging().appDidReceiveMessage(userInfo)
    // Print message ID.
    if let messageID = userInfo[gcmMessageIDKey] {
        print("Message ID: \(messageID)")
    }

    let aps = userInfo["aps"] as! [String: AnyObject]
    // 1
    if aps["content-available"] as? Bool == true {
        let uuid = UUID(uuidString: MyVariables.uuid)

        AppDelegate.shared.displayIncomingCall(uuid: uuid!, handle: "Sanoste", hasVideo: false) { _ in}

    }else  {
        completionHandler(UIBackgroundFetchResult.newData)
    }

    // Print full message.
    print(userInfo)

    completionHandler(UIBackgroundFetchResult.newData)

}

上面的代码是我现在用于 CallKit 的代码。

【问题讨论】:

    标签: ios swift firebase firebase-cloud-messaging callkit


    【解决方案1】:

    据我了解,呼叫套件 + 推送套件是为了让应用在用户强制退出后激活。您需要发送一个特殊的 VOIP 推送通知,该通知使用您在 developer.apple.com 的证书、标识符和配置文件部分配置的 voip 推送证书。

    所以从我看来,你的方法是倒退的。您应该使用外部服务器发送 voip 推送通知,该通知将唤醒您的应用程序以处理通知......然后执行您需要的任何其他处理。

    此外,您还需要指出您的应用正在使用 VOIP 后台模式。另外值得注意的是,如果您实际上没有按预期使用 VOIP,那么苹果很可能会拒绝您进入应用商店。

    【讨论】:

    • 您好,感谢您的回复。我昨天用 VOIP 开发证书进行了测试,一切都按我的预期工作。但是,您是对的,我们的团队缺少一个“真实”的 Voip 后端,而不是仅使用 pushkit 来推送通知。我认为我们的团队必须再次讨论或向苹果寻求帮助。无论如何,再次感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-03
    • 2023-03-28
    相关资源
    最近更新 更多