ios - 本地通知应用程序崩溃模拟器
<p><p>我将本地通知插件 (<a href="https://github.com/katzer/cordova-plugin-local-notifications/" rel="noreferrer noopener nofollow">https://github.com/katzer/cordova-plugin-local-notifications/</a>) 与 ng-cordova 一起用于 ionic 项目:</p>
<p>这是我的 Controller :</p>
<pre><code>.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');
});
};
})
</code></pre>
<p>我在默认 View 上有一个按钮,当应用程序以 ng-click 启动时加载,如下所示:</p>
<pre><code><button ng-click="addNotification();" class="button button-stable">button-stable</button>
</code></pre>
<p>但是当我在模拟器中运行应用程序并点击按钮时,应用程序崩溃并显示以下错误消息:</p>
<pre><code>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- : 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 - + 275
3 CoreFoundation 0x002bc50b forwarding + 1019
4 CoreFoundation 0x002bc0ee CFforwarding_prep_0 + 14
5 new 0x0011f917 - + 503
6 new 0x0011f6a6 - + 86
7 new 0x0011bccf __28-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 : Application 'UIKitApplication:com.ionicframework.new903016' exited abnormally with signal 6: Abort trap: 6"
</code></pre>
<p>有没有人按照 ng-cordova 文档让它工作,或者我应该尝试另一种方法。</p>
<p>谢谢!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>如果你仍然有这个问题,我今天也遇到了这个问题。 </p>
<p>进入插件代码,Xcode 中的 APPLocalNotifications.m 并将这一行更改为底部:</p>
<p><code>NSString* notId = [
字符串值];</code></p>
<p>并将其替换为:</p>
<p><code>NSString* notId = ;</code></p>
<p>今天这对我有用。 </p></p>
<p style="font-size: 20px;">关于ios - 本地通知应用程序崩溃模拟器,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/26450016/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/26450016/
</a>
</p>
页:
[1]