ios html5 推送,uniapp判断iOS系统推送通知功能是否开启,没开启提醒去设置打开...

本文介绍了在uniapp项目中遇到的‘plus.ios.importisnotafunction’错误,特别是在自定义模式下。该问题在HBuilderX 1.9.4.20190426之后的版本已被修复。内容涉及到检查和处理用户推送通知的设置,包括如何引导用户开启推送,并提供了相应的代码示例。
摘要由CSDN通过智能技术生成

function isOpenPush() {

var UIApplication = plus.ios.import("UIApplication");

var app = UIApplication.sharedApplication();

var enabledTypes = 0;

if (app.currentUserNotificationSettings) {

var settings = app.currentUserNotificationSettings();

enabledTypes = settings.plusGetAttribute("types");

console.log("enabledTypes1:" + enabledTypes);

if (enabledTypes == 0) {

plus.nativeUI.confirm("推送设置没有开启,是否去开启?", function(e) {

if (e.index == 0) {

var NSURL2 = plus.ios.import("NSURL");

var setting2 = NSURL2.URLWithString("app-settings:");

var application2 = UIApplication.sharedApplication();

application2.openURL(setting2);

plus.ios.deleteObject(setting2);

plus.ios.deleteObject(NSURL2);

plus.ios.deleteObject(application2);

}

}, {

"buttons": ["Yes", "No"],

"verticalAlign": "center"

});

}

plus.ios.deleteObject(settings);

} else {

enabledTypes = app.enabledRemoteNotificationTypes();

if(enabledTypes == 0){

console.log("推送未开启!");

}else{

console.log("已经开启推送功能!")

}

console.log("enabledTypes2:" + enabledTypes);

}

plus.ios.deleteObject(app);

}

此功能在uniapp项目且配置为自定义模式的时候,会报:“plus.ios.import is not a function”错误。

该问题已经在HBuilderX1.9.4.20190426 之后版本已经解决

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值