← All extensions

Native extension

KlugPush

com.klug.push.Push

Remote push notifications for AIR apps on the Mac, with the live permission status and a shortcut to the system settings.

macOS In production

Overview

KlugPush brings remote push notifications to AIR apps on macOS. It registers the app with Apple's push notification service, gives you the device token for your server, and delivers incoming notifications to ActionScript.

On macOS a user who once declined notifications is not asked again. KlugPush therefore reports the current permission status at any time and opens the Notifications page in System Settings, so users can turn notifications on later.

KlugPush is in daily use in the PetCam App for the Mac, our proof of concept.

Features

  • Asks for permission and registers for remote notifications
  • Device token for your server, as soon as registration finishes
  • Incoming notifications delivered to ActionScript as JSON
  • Live permission status: not yet decided, denied or allowed
  • Opens System Settings directly at Notifications
  • Sent straight through Apple's push service, no extra push provider needed

Supported platforms

macOS Apple silicon · Intel

On other platforms isSupported returns false, so the same code can stay in a cross-platform app.

Getting started

Add the extension to your application descriptor:

app.xml
<extensions>
    <extensionID>com.klug.push.Push</extensionID>
</extensions>

The app must be signed with the push notifications entitlement and a provisioning profile that includes the Push Notifications capability.

Quick example

Register
Push.as
import com.klug.push.Push;

var push:Push = Push.getInstance();
if ( push.isSupported )
{
    push.register(
        function( token:String ):void { sendTokenToServer( token ); },
        function( error:String ):void { trace( error ); },
        function( json:String ):void { showNotification( json ); } );
}
Permission status
Settings.as
push.refreshStatus( function( status:int ):void
{
    if ( status == Push.STATUS_DENIED )
        push.openSettings();   // let the user turn notifications on
} );

API overview

Push.getInstance()Returns the single instance.
isSupportedTrue on macOS.
register(onToken, onError, onNotification)Asks for permission and registers for remote notifications.
tokenThe last device token, or null until registration finishes.
authStatusThe last known permission status.
refreshStatus(onStatus)Reads the current permission status.
openSettings()Opens System Settings at Notifications.
STATUS_NOT_DETERMINED, STATUS_DENIED, STATUS_AUTHORIZEDPermission status values.
StatusEvent: token, error, notificationThe same results as events, for listeners.

Requirements

AIR SDK51.x (HARMAN)
macOSmacOS 11 or later
SigningPush notifications entitlement and a matching provisioning profile
ServerSends notifications through Apple's push service