Skip to main content

FCM Registration

Overview#

This document describes how to configure the push notification feature in the GCCS authentication process.


Feature Description#

There can be a circumstance when the user requests GCCS authentication from a non-mobile platform such as the web or window.
To receive the push notification in the mobile app that has implemented the Android SDK, FCM registration and the token update feature is necessary.

FCM Server key#

In order to receive the push notifications, the server key generated by Firebase Cloud Messaging (FCM) must be sent together with the client issuance request. The FCM server key can be found in the process below.

  1. Create or load the project in the Firebase Console.
  2. [Project Settings] > get the Server Key from [Cloud Messaging] menu.

If the client needs registration, note that the FCM server key is indispensable.

FCM Push notification token registration#

FCM push token should be registered so that it can be used for notifying authentication request. By using the registerPushToken() from GuardianSdk, the FCM push token that was generated from the Android device can be called to be registered and updated.

FCM push token can be changed due to expiration, etc. It should be updated by calling registerPushToken().

Parameter#

KeyValueDescription
tokenStringFCM push notification token

Example#

// FCM Push notification token registeredFirebaseInstanceId.getInstance().getInstanceId()    .addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {        public void onSuccess(InstanceIdResult instanceIdResult) {            String token = instanceIdResult.getToken();
            GuardianSdk.getInstance().registerPushToken(token, new GuardianResponseCallback<ResultResponse>() {                @Override                public void onSuccess(ResultResponse result) {                    Log.i(TAG, "Result code : " + result.rtCode);                }                @Override                public void onFailed(ErrorResult errorResult) {                    Log.e(TAG, "Error code : " + errorResult.getErrorCode());                }            });        }});
// FCM Push notification token renewedpublic class FirebasePushService extends FirebaseMessagingService {    @Override    public void onMessageReceived(RemoteMessage remoteMessage) {    }
    @Override    public void onNewToken(String token) {        super.onNewToken(token);        GuardianSdk.getInstance().registerPushToken(token, new GuardianResponseCallback<ResultResponse>() {            @Override            public void onSuccess(ResultResponse result) {                Log.i(TAG, "Result code : " + result.rtCode);            }
            @Override            public void onFailed(ErrorResult errorResult) {                Log.e(TAG, "Error code : " + errorResult.getErrorCode());            }        });    }}

ResultResponse#

KeyValueDescription
rtCode0Result code
rtMsgStringResult message

If the API call to register FCM push token is successful, the rtCode will be 0

ErrorResult#

KeyValueDescription
errorCodeIntError code
errorMessageStringError message

If API call fails, the user will receive an errorCode


FCM Push Message Transfer#

If requesting an authentication on web or window with using user key, a message is transferred through FCM on mobile application. In case of receiving a push message after an authentication, it proceeds an authentication process by calling authMessageProcessing of GuardianSdk.

Parameter#

KeyValueDescription
remoteMessageMap<String,String>Authentication push message

Example#

public class FirebasePushService extends FirebaseMessagingService {    @Override    public void onMessageReceived(RemoteMessage remoteMessage) {         GuardianSdk.getInstance().authMessageProcessing(remoteMessage.data)    }
    @Override    public void onNewToken(String token) {}
}
---