Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thanks1234/614bfc09dfa175613745 to your computer and use it in GitHub Desktop.
Save thanks1234/614bfc09dfa175613745 to your computer and use it in GitHub Desktop.
Very simple example of displaying a local notification.
import com.distriqt.extension.notifications.Notifications;
import com.distriqt.extension.notifications.Notification;
import com.distriqt.extension.notifications.events.NotificationEvent;
var count:int = 2;
try
{
Notifications.init( APP_KEY );
Notifications.service.addEventListener( NotificationEvent.NOTIFICATION_SELECTED, notifications_notificationSelectedHandler, false, 0, true );
//
// This will trigger the start up notification if the application was started from a delayed notification
// Also this will perform the required registration for notifications permission on iOS 8+
Notifications.service.register();
if (Notifications.isSupported)
{
var notification:Notification = new Notification();
notification.tickerText = "Hello";
notification.title = "My Notification";
notification.body = "Hello World";
notification.delay = 10; // seconds
++count;
Notifications.service.setBadgeNumber( count );
Notifications.service.notify( notification.id, notification );
}
}
catch (e:Error)
{
}
...
function notifications_notificationSelectedHandler( event:NotificationEvent ):void
{
Notifications.service.cancel( event.id );
count --;
Notifications.service.setBadgeNumber( count );
}
// com.distriqt.Notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment