[英]Local notification phonegap ios
I'm using Local Notification plugin for a phonegap iOS app. 我正在为Phonegap iOS应用程序使用本地通知插件 。 When I try to add a new Notification, the app throw a NSInvalidArgumentException.
当我尝试添加新的Notification时,应用程序抛出NSInvalidArgumentException。
Here is the code when i add a notification: 这是我添加通知时的代码:
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
});
And here is the output 这是输出
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa26c650'
*** First throw call stack:
(
0 CoreFoundation 0x000dd1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x021948e5 objc_exception_throw + 44
2 CoreFoundation 0x0017a243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x000cd50b ___forwarding___ + 1019
4 CoreFoundation 0x000cd0ee _CF_forwarding_prep_0 + 14
5 OPS 0x000276e9 -[APPLocalNotification notificationWithId:] + 521
6 OPS 0x00027246 -[APPLocalNotification isNotificationScheduledWithId:] + 86
7 OPS 0x00023458 __28-[APPLocalNotification add:]_block_invoke + 200
8 libdispatch.dylib 0x027527b8 _dispatch_call_block_and_release + 15
9 libdispatch.dylib 0x027674d0 _dispatch_client_callout + 14
10 libdispatch.dylib 0x02755eb7 _dispatch_root_queue_drain + 291
11 libdispatch.dylib 0x02756127 _dispatch_worker_thread2 + 39
12 libsystem_pthread.dylib 0x02a96dab _pthread_wqthread + 336
13 libsystem_pthread.dylib 0x02a9acce start_wqthread + 30
)
libc++abi.dylib: terminating with uncaught exception of type NSException
any idea? 任何想法? Thank you.
谢谢。
您的id参数不是字符串,但是插件似乎需要id的字符串值。
I find the solution. 我找到了解决方案。 If you are using iOS 7.1, you must replace this line
如果您使用的是iOS 7.1,则必须替换此行
NSString* notId =[notification.userInfo objectForKey:@"id"];
for this 为了这
NSString* notId =[NSString stringWithFormat:@"%@", [notification.userInfo objectForKey:@"id"]];
in the method notificationWithId. 在方法notifyWithId中。
Thanks for the help! 谢谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.