• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 本地通知应用程序崩溃模拟器

[复制链接]
菜鸟教程小白 发表于 2022-12-13 09:35:54 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我将本地通知插件 (https://github.com/katzer/cordova-plugin-local-notifications/) 与 ng-cordova 一起用于 ionic 项目:

这是我的 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');
            });
    };
})

我在默认 View 上有一个按钮,当应用程序以 ng-click 启动时加载,如下所示:

  <button ng-click="addNotification();" class="button button-stable">button-stable</button>

但是当我在模拟器中运行应用程序并点击按钮时,应用程序崩溃并显示以下错误消息:

: *** 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 文档让它工作,或者我应该尝试另一种方法。

谢谢!



Best Answer-推荐答案


如果你仍然有这个问题,我今天也遇到了这个问题。

进入插件代码,Xcode 中的 APPLocalNotifications.m 并将这一行更改为底部:

NSString* notId = [[notification.userInfo objectForKey"id"] 字符串值];

并将其替换为:

NSString* notId = [notification.userInfo objectForKey"id"];

今天这对我有用。

关于ios - 本地通知应用程序崩溃模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26450016/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap