|
/

注册拿不到deviceToken

Ss*
发布于 2 年前
1299来自广东省
消息推送 U-Push
API调用

这个代码吃掉下边这个系统回调了,拿不到deviceToken,直接调系统那个 UIApplication.shared.registerForRemoteNotifications()可以拿到。这是为什么?有人遇到么? 跟swiftUI项目有关????
UMessage.registerForRemoteNotifications(launchOptions: launchOptions, entity: createNotificationEntity(), completionHandler: { granted, error in

print("授权状态:\(granted)")

if granted {

DispatchQueue.main.async {

UNUserNotificationCenter.current().delegate = self

UIApplication.shared.registerForRemoteNotifications()

print("授权注册状态:\(UIApplication.shared.isRegisteredForRemoteNotifications)")

}

}

})

// 注册成功回调,获取 deviceToken

func application(_ application: UIApplication,

didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

UMessage.registerDeviceToken(deviceToken)

// 转成16进制字符串

let tokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()

// 打印出来

print("✅ deviceToken: \(tokenString)")

}

1个回答
 
1 年前
来自浙江省

你好,建议可参考文档https://developer.umeng.com/docs/67966/detail/66734

Loading ...
登录社区,分享你的经验