卡卡LL
卡卡LL
  • 发布:2024-06-05 21:01
  • 更新:2024-06-05 21:01
  • 阅读:65

ios使用nativejs请求消息通知权限

分类:Native.js

const UNUserNotificationCenter = plus.ios.import('UNUserNotificationCenter');
const center = UNUserNotificationCenter.currentNotificationCenter();
const UNAuthorizationOptions = {
alert: 4,
badge: 1,
sound: 2,
carPlay: 8,
criticalAlert: 16,
providesAppNotificationSettings: 32,
provisional: 64,
announcement: 128,
};
plus.ios.invoke(center,'requestAuthorization',{
options:[UNAuthorizationOptions.alert],
completionHandler:(granted, error) => {
if (error) {
console.error(error);
} else {
if (granted) {
plus.ios.invoke(plus.ios.import("UIApplication").sharedApplication(), "registerForRemoteNotifications");
callback(true);
} else {
callback(false);
}
}

},)

上面这段代码弹不出权限请求弹窗,请问是没有requestAuthorization这个方法还是传参方式不对,应该如何写了?

2024-06-05 21:01 负责人:无 分享
已邀请:

要回复问题请先登录注册