Forked from marchbold/distriqt.extension.notifications.example.as
Last active
August 29, 2015 14:12
-
-
Save thanks1234/614bfc09dfa175613745 to your computer and use it in GitHub Desktop.
Very simple example of displaying a local notification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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