Messaging Get Started - tuarua/Firebase-ANE GitHub Wiki
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.
-
Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab.
-
In APNs authentication key under iOS app configuration, click the Upload button.
-
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
- Update [YOUR FCM TOKEN] value with the latest FCM Token
- 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