小编Gor*_*hez的帖子

Request authorization for remote notifications always return false at first start

request authorization for push notifications always return false when app is first loaded even user tap "allow" on dialog. Here is function for register which is called in didFinishLaunchingWithOptions. At next launch granted is true.

func registerForPushNotifications() {
        UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
            (granted, error) in
            print("Permission granted: \(granted)")
            guard granted else{return}
            self.getNotificationSettings()
        }
}
Run Code Online (Sandbox Code Playgroud)

push-notification ios swift

4
推荐指数
1
解决办法
2021
查看次数

标签 统计

ios ×1

push-notification ×1

swift ×1