本人不会objective-c,根据文档示例写了个IOS原生方法创建本地通知,代码可以正常运行,程序中的日志都能正常打印,但通知没有显示出来,不知道是什么原因,大神帮忙看下
/**
* IOS原生方法
* @param {Object} contentTitle
* @param {Object} contentText
* @param {Object} smallIcon
*/
function createLocalMessageForIOS(contentTitle, contentText, smallIcon){
console.log('ios begin.');
var UILocalNotification = plus.ios.importClass("UILocalNotification");
// 创建UILocalNotification类的实例对象
var localNotification = new UILocalNotification();
//设置调用时间
var NSDate = plus.ios.importClass('NSDate');
var myNSDate = new NSDate();
myNSDate.dateWithTimeIntervalSinceNow = 1; //1秒后触发
localNotification.fireDate = myNSDate;
localNotification.alertBody = contentText;
localNotification.applicationIconBadgeNumber = 3;
localNotification.alertAction = '打开应用!';
localNotification.alertLaunchImage = 'Default';
localNotification.soundName = UILocalNotification.DefaultSoundName;
var UIApplication = plus.ios.importClass("UIApplication");
var myUIApplication = new UIApplication();
myUIApplication.scheduleLocalNotification = localNotification;
//销毁对象实例
plus.ios.deleteObject( localNotification );
plus.ios.deleteObject( myUIApplication );
plus.ios.deleteObject( myNSDate );
console.log('ios end.');
}
0 个回复