Le *_*iet 1 ios firebase swift firebase-cloud-messaging callkit
我正在开发一个使用CallKit通知用户的应用程序.但是,我正在使用APN测试应用程序,但它无法正常工作.
流程应为:接收FCM - >使用Callkit创建呼叫 - >用户接受呼叫 - >执行某些操作.
流程类似于应用程序类似于什么,但我没有VOIP,我只需要确保CALLKIT激活每个时间都有一个FCM.
但是,目前,如果应用程序处于后台或非活动状态,则callkit将无法启动.
我正在考虑使用PushKit来实现它.但是,我没有使用PushKit的经验(并且不确定我的应用程序是否会被禁止,根据这篇文章:PushKit:我们可以在聊天应用程序中使用推送套件(VoiP推送)而无需使用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)
}
Run Code Online (Sandbox Code Playgroud)
上面的代码就是我现在正在使用的CallKit.
从我对call kit + push kit的理解是为了让用户强行退出后让应用程序变为活动状态.您需要发送一个特殊的VOIP推送通知,该通知使用您在developer.apple.com的"证书,标识符和配置文件"部分中配置的voip推送证书.
所以从我看到的是你的方法是倒退的.您应该使用外部服务器发送voip推送通知,该通知将唤醒您的应用程序以处理通知...然后执行您需要的任何其他处理.
此外,您还需要指明您的应用正在使用VOIP后台模式.而且值得注意的是,如果您实际上没有按预期使用VOIP,那么苹果很可能会拒绝您从应用程序商店.
| 归档时间: |
|
| 查看次数: |
2652 次 |
| 最近记录: |