本地通知phonegap ios
我正在使用phonegap iOS应用程序。当我尝试添加新通知时,应用程序会抛出NSInvalidArgumentException 以下是我添加通知时的代码:本地通知phonegap ios,ios,cordova,phonegap-plugins,localnotification,Ios,Cordova,Phonegap Plugins,Localnotification,我正在使用phonegap iOS应用程序。当我尝试添加新通知时,应用程序会抛出NSInvalidArgumentException 以下是我添加通知时的代码: var now = new Date().getTime(), _60_seconds_from_now = new Date(now + 60*1000); window.plugin.notification.local.add({
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 60*1000);
window.plugin.notification.local.add({
id: 1,
title: 'Reminder',
message: 'Dont forget to buy some flowers.',
repeat: false,
date: _60_seconds_from_now
});
这是输出
有什么想法吗?多谢各位 您的id参数不是字符串,但插件似乎需要id的字符串值。我找到了解决方案。如果您使用的是iOS 7.1,则必须更换该行
NSString* notId =[notification.userInfo objectForKey:@"id"];
为此
NSString* notId =[NSString stringWithFormat:@"%@", [notification.userInfo objectForKey:@"id"]];
在方法notificationWithId中
谢谢你的帮助 您从本机端收到错误,您传递的参数之一可能与预期的类型不同。您可以在xcode中调试并轻松解决问题。还有可能有几个本地通知插件,我不知道你在使用哪个。嗨@mentat,我也在使用这个插件,我在xcode中调试过,没有发现任何奇怪的地方
NSString* notId =[NSString stringWithFormat:@"%@", [notification.userInfo objectForKey:@"id"]];