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这个方法还是传参方式不对,应该如何写了?
0 个回复