钛移动本地通知崩溃
我对本地通知有疑问。尝试通过本地通知返回应用程序时,应用程序崩溃。 我复制了 Kitchen Sink 示例,但对 bg.js 进行了一些修改。 在 bg.js 中,有这样的内容:
Titanium.App.addEventListener('whatever', function(e){
var myNotification = Titanium.App.iOS.scheduleLocalNotification({
alertBody: msg_body,
alertAction: "Yup",
userInfo: {"key": "value"},
date:new Date(new Date().getTime())
});
});
嗯,这不是我的确切代码,但这就是精神。我试图删除所有无用的东西,但找不到答案...... 这是崩溃报告标题: https://gist.github.com/956064 这是一个有记录的问题吗?
编辑:代码中的拼写错误。
I have a problem with local notifications. App crashes when trying to get back in app with local notification.
I copied the Kitchen Sink sample but modified a bit the bg.js.
In bg.js, there is something like this:
Titanium.App.addEventListener('whatever', function(e){
var myNotification = Titanium.App.iOS.scheduleLocalNotification({
alertBody: msg_body,
alertAction: "Yup",
userInfo: {"key": "value"},
date:new Date(new Date().getTime())
});
});
Well, this is not my exact code, but this is the spirit. I tried to remove everything useless, but can't find the answer...
Here is the crash report header: https://gist.github.com/956064
Is this is a somewhat documented problem?
EDIT: typo in code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不能以一种或另一种方式谈论您对事件侦听器的使用,但这里的核心问题是应用程序崩溃。这是因为您正在创建多个具有相同变量名的 localNotifications。问题的解决方案是确保每次安排 localNotification 时不使用相同的变量名称,因此请使用数组之类的东西。我遇到了同样的问题,花了 30 秒修复了将定义放入数组中的问题,如下所示:
I cannot speak one way or the other to your use of an event listener, but the core problem here is the application crashing. This is caused because you are creating multiple localNotifications with the same variable name. The solution to your problem is to ensure that you do not use the same variable name each time you schedule a localNotification, so use something like an array instead. I had the same problem and it was a 30 second fix to toss the definition into an array, as such:
主要问题是
userInfo
字段未填充,这会导致 NCFDictionary 出现异常。将空对象{}
分配给userInfo
可以解决该问题:The main issue is that
userInfo
field is not filled, which causes an exception in NCFDictionary. Assigning an empty object{}
touserInfo
solves the issue: