Titanium 钛-应用程序只显示一次通知
我的应用程序有时会显示多个android通知。当有人点击他们时,我的应用程序会显示通知的内容。 我已经设法做到了,但它只适用于用户单击的第一个通知。如果在此之后离开应用程序(例如使用homebutton),然后单击下一个通知,则不会发生任何事情 我创建了一个示例应用程序,向您展示我目前拥有的功能。你可以在这里找到它: 我做错了什么?我如何实现我想要的 app.jsTitanium 钛-应用程序只显示一次通知,titanium,android-notifications,Titanium,Android Notifications,我的应用程序有时会显示多个android通知。当有人点击他们时,我的应用程序会显示通知的内容。 我已经设法做到了,但它只适用于用户单击的第一个通知。如果在此之后离开应用程序(例如使用homebutton),然后单击下一个通知,则不会发生任何事情 我创建了一个示例应用程序,向您展示我目前拥有的功能。你可以在这里找到它: 我做错了什么?我如何实现我想要的 app.js if(!Ti.App.Properties.getBool("displayedNotifications")){ var
if(!Ti.App.Properties.getBool("displayedNotifications")){
var notifications = ["Apple","Orange","Banana"];
for(var i = 0; i < notifications.length; i++){
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
packageName:"com.company.notificationtest",
className:"com.company.notificationtest.NotificationtestActivity",
flags:Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP
});
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
intent.putExtra("name",notifications[i]);
Titanium.Android.NotificationManager.notify(i, Titanium.Android.createNotification({
contentTitle: notifications[i],
contentText : notifications[i],
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY
}),
flags : Titanium.Android.ACTION_DEFAULT | Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS
}));
}
Ti.App.Properties.setBool("displayedNotifications",true);
}
if(!Ti.App.Properties.getBool(“displayedNotifications”)){
var通知=[“苹果”、“橘子”、“香蕉”];
for(var i=0;i
tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<id>com.company.notificationtest</id>
<name>NotificationTest</name>
<version>1.0</version>
<publisher>not specified</publisher>
<url></url>
<description>not specified</description>
<copyright>not specified</copyright>
<icon>appicon.png</icon>
<fullscreen>false</fullscreen>
<navbar-hidden>false</navbar-hidden>
<analytics>true</analytics>
<guid>91e86075-373b-44e0-9416-66183390e8af</guid>
<property name="ti.ui.defaultunit" type="string">dp</property>
<android xmlns:android="http://schemas.android.com/apk/res/android">
</android>
<modules>
</modules>
<deployment-targets>
<target device="android">true</target>
</deployment-targets>
<sdk-version>3.2.3.GA</sdk-version>
</ti:app>
com.company.notificationtest
通知测试
1
未指定
未指定
未指定
appicon.png
错误的
错误的
符合事实的
91e86075-373b-44e0-9416-66183390e8af
数据处理
符合事实的
3.2.3.GA
更改:
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY
}),
致:
帮我修好。使用3.3.0.GA进行测试。使用最新的SDK时,您是否遇到同样的问题?i、 e.3.3.0.GA?遗憾的是,它也不适用于SDK 3.3.0.GA。。。有什么想法吗?当你编译它时它能工作吗?它在3.3.0.GA中为我运行过,我可以重现你所说的问题。然而,我不认为这是钛的固有问题,因为我刚刚提出的要点是正确的:耶稣!这就解决了!!谢谢你,接受我的赏金:)
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY
}),