I’m using the local notification plugin (https://github.com/katzer/cordova-plugin-local-notifications/) with ng-cordova:
This is my controller:
.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>
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 _CF_forwarding_prep_0 + 14
5 new 0x0011f917 -[APPLocalNotification notificationWithId:] + 503
6 new 0x0011f6a6 -[APPLocalNotification isNotificationScheduledWithId:] + 86
7 new 0x0011bccf __28-[APPLocalNotification add:]_block_invoke + 207
8 libdispatch.dylib 0x0293d7b8 _dispatch_call_block_and_release + 15
9 libdispatch.dylib 0x029524d0 _dispatch_client_callout + 14
10 libdispatch.dylib 0x02940eb7 _dispatch_root_queue_drain + 291
11 libdispatch.dylib 0x02941127 _dispatch_worker_thread2 + 39
12 libsystem_pthread.dylib 0x02c89dab _pthread_wqthread + 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"
Thera are a couple of questions about ng-cordova and the local notification plugin in the forum. Has anyone got it to work following the ng-cordova docs, or is ther another approach I should be trying.
Thank’s!