本地通知应用程式会导致模拟器崩溃 [英] Local notification app crashes simulator
问题描述
我使用的是本地通知插件( https://github.com/
I'm using the local notification plugin (https://github.com/katzer/cordova-plugin-local-notifications/) with ng-cordova for an ionic poject:
这是我的控制器:
.controller('DashCtrl', function($scope, $state, $cordovaLocalNotification) {
$scope.addNotification = function() {
$cordovaLocalNotification.add({
id: 'some_notification_id'
// parameter documentation:
// https://github.com/katzer/cordova-plugin-local-notifications#further-informations-1
}).then(function() {
console.log('callback for adding background notification');
});
};
$scope.checkIfIsTriggered = function() {
$cordovaLocalNotification.isTriggered('some_notification_id').then(
function(isTriggered) {
alert('isTriggered');
});
};
})
我在应用程序启动时加载的默认视图上有一个按钮如下所示:
I have a button on the default view which is loaded when the app starts with a ng-click, like so:
<button ng-click="addNotification();" class="button button-stable">button-stable</button>
但是当我在模拟器中运行应用程序,并点击按钮,应用程序崩溃与followiing错误消息:
But when I run the app in the emulator and tap the button, the app crashes with the followiing error message:
: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFString stringValue]: unrecognized selector sent to instance 0x7a840850'
*** First throw call stack:
(
0 CoreFoundation 0x002cc1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x023848e5 objc_exception_throw + 44
2 CoreFoundation 0x00369243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x002bc50b forwarding + 1019
4 CoreFoundation 0x002bc0ee CFforwarding_prep_0 + 14
5 new 0x0011f917 -[APPLocalNotification notificationWithId:] + 503
6 new 0x0011f6a6 -[APPLocalNotification isNotificationScheduledWithId:] + 86
7 new 0x0011bccf __28-[APPLocalNotification add:]blockinvoke + 207
8 libdispatch.dylib 0x0293d7b8 dispatchcall_block_and_release + 15
9 libdispatch.dylib 0x029524d0 dispatchclient_callout + 14
10 libdispatch.dylib 0x02940eb7 dispatchroot_queue_drain + 291
11 libdispatch.dylib 0x02941127 dispatchworker_thread2 + 39
12 libsystem_pthread.dylib 0x02c89dab pthreadwqthread + 336
13 libsystem_pthread.dylib 0x02c8dcce start_wqthread + 30
)
Oct 19 11:54:21 xxxx-MacBook-Air.local backboardd[27466] : Application 'UIKitApplication:com.ionicframework.new903016[0xde04]' exited abnormally with signal 6: Abort trap: 6"
有人根据ng-cordova文档使其工作,
Has anyone got it to work following the ng-cordova docs, or is there another approach I should be trying.
推荐答案
如果你还有这个问题,今天我也遇到了这个问题。
If you're still having this issue, I ran into this today as well.
转到Xcode中的插件代码APPLocalNotifications.m,并将此行更改为底部:
Go into the plugin code, APPLocalNotifications.m in Xcode and change this line, towards the bottom:
NSString * notId = [[notification.userInfo objectForKey:@id]
stringValue];
并将其替换为:
NSString * notId = [notification.userInfo objectForKey:@id];
这对我今天有用。
这篇关于本地通知应用程式会导致模拟器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!