uniapp判断APP是否有通知权限,安卓和IOS都有。并跳转到开启通知页面
/**
* 获取通知状态
*/
getNotificationStatus() {
// #ifdef APP-PLUS
let osName = plus.os.name.toLowerCase();
if(osName == 'ios'){
let UIApplication = plus.ios.import("UIApplication");
let app = UIApplication.sharedApplication();
let enabledTypes = 0;
if (app.currentUserNotificationSettings) {
let settings = app.currentUserNotificationSettings();
enabledTypes = settings.plusGetAttribute("types");
} else {
//针对低版本ios系统
enabledTypes = app.enabledRemoteNotificationTypes();
}
plus.ios.deleteObject(app);
if (0 == enabledTypes) {
// 未开启通知
uni.$showModal({
title: "提示",
content: '开启通知权限后才能收到提示消息哦。',
delCancel: false,
confirmVal: '去开启',
cancelVal: '取消',
}).then(res => {
let UIApplication = plus.ios.import("UIApplication");