适用于Android的Appcelerator Titanium LocalNotification

Kar*_*amy 5 android titanium appcelerator push-notification appcelerator-mobile

是否在Android中有任何LocalNotification.(有些东西类似于Titanium.App.iOS.scheduleLocalNotification)

即使我的应用程序关闭,我也需要Android平台的一些简单通知(如警报).Titanium有可能吗?

The*_*ero 8

在Android中,您也可以触发通知,但不会显示为警告框.相反,它将显示在通知区域中.这是在android中触发通知的代码片段.

alarmTimeIntent = Ti.Android.createIntent({
                className: 'org.appcelerator.titanium.TiActivity',
                packageName: 'package name here',
                flags: Titanium.Android.FLAG_ACTIVITY_CLEAR_TOP | Titanium.Android.FLAG_ACTIVITY_SINGLE_TOP 
            });

            var alarmTimePendingIntent = Ti.Android.createPendingIntent({
                activity: Ti.Android.currentActivity,
                intent: alarmTimeIntent,
                type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
                flags: Titanium.Android.FLAG_CANCEL_CURRENT
            });

            var alarmTimeNotification = Titanium.Android.createNotification({
                contentIntent: alarmTimePendingIntent,
                contentTitle: 'Content Title Here',
                tickerText: 'Ticker text here',
                defaults:Titanium.Android.NotificationManager.DEFAULT_SOUND,
                when: new Date()
            });

            Ti.Android.NotificationManager.notify(1, alarmTimeNotification);
Run Code Online (Sandbox Code Playgroud)