Swift推送通知,但仅发送“内容可用”,我需要征求用户许可

时间:2018-11-04 23:06:12

标签: swift apple-push-notifications

我正在开发一个使用服务器数据的快速应用程序。 要启动“获取数据”命令,我使用的消息正文为

的APNS
$body['aps'] = array(
    'content-available' => 1
);

这显然会触发

func application(
    _ application: UIApplication,
    didReceiveRemoteNotification userInfo: [AnyHashable : Any],
    fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

然后我调用函数来获取服务器数据。

由于即时通讯没有显示通知,我必须要求用户许可吗? 即

    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {

0 个答案:

没有答案