API Reference

com.kinvey.android.push

Class FCMPush

  • AbstractPush
    • com.kinvey.android.push.FCMPush


  • public class FCMPush
    extends AbstractPush

    This functionality can be accessed through the Client.push ()} convenience method.

    This class manages FCM Push for the current logged in user. Use fcm.enabled=true in the kinvey.properties file to enable FCM.

    sample usage:

    This code snippet will enable push notifications through FCM for the current logged in user.

    See Also:
    Client.push
    • Field Detail

      • SHARED_PREF

        public static java.lang.String SHARED_PREF
      • PREF_REG_ID

        public static java.lang.String PREF_REG_ID
    • Constructor Detail

      • FCMPush

        public FCMPush(Client<?> client,
                       boolean inProduction,
                       java.lang.String[] senderIDs)

        This functionality can be accessed through the Client.push ()} convenience method.

        This class manages FCM Push for the current logged in user. Use fcm.enabled=true in the kinvey.properties file to enable FCM.

        sample usage:

        This code snippet will enable push notifications through FCM for the current logged in user.

        See Also:
        Client.push
    • Method Detail

      • initialize

        public FCMPush initialize(android.app.Application currentApp)

        Initialize FCM by registering the current user with both FCM as well as your backend at Kinvey.

        Note these operations are performed asynchronously, however there is no callback. Instead, updates are delegated to your custom KinveyFCMService which will handle any responses.

        Parameters:
        currentApp -
        • The current valid application context.

        Returns:
        an instance of FCM push, initialized for the current user.
      • registerWithKinvey

        public void registerWithKinvey(java.lang.String fcmRegID,
                                       boolean register)
      • getPushId

        public java.lang.String getPushId()

        Get the InstanceID from FCM for the Client's current application context.

        Note if the current user is not registered, the registration ID will be an empty string.

        Returns:
        • the current user's FCM InstanceID or an empty string ""

      • isPushEnabled

        public boolean isPushEnabled()

        Check to see if the current user is registered for FCM. This checks both with FCM directly as well as with a Kinvey backend.

        Returns:
        true if current user is registered, false if they are not.
      • disablePush

        public void disablePush()

        Unregisters the current user with FCM

        Unregistration is asynchronous, so use the KinveyFCMService to receive notification when unregistration has completed.

      • getSenderIDs

        public java.lang.String[] getSenderIDs()

        Get a list of all sender IDs as an array

        Returns:
        an array of sender IDs
      • setSenderIDs

        public void setSenderIDs(java.lang.String[] p)

        Get a list of all sender IDs as an array

      • enablePushViaRest

        public void enablePushViaRest(com.kinvey.java.core.KinveyClientCallback<java.lang.Object> callback,
                                      java.lang.String deviceID)

        Async wrapper for enabling push notification for the current user

        Parameters:
        callback -
        • a callback with results of registration

        deviceID -
        • the current device's unique id from GCM

      • disablePushViaRest

        public void disablePushViaRest(com.kinvey.java.core.KinveyClientCallback<java.lang.Object> callback,
                                       java.lang.String deviceID)

        Async wrapper for disabling push notifications for the current user

        Parameters:
        callback -
        • a callback with results of unregistration

        deviceID -
        • the current device's unique id from GCM

      • isInProduction

        public boolean isInProduction()

        Is FCM Push configured for production or a dev environment?

        Returns:
        true if in production mode, false if not
      • setInProduction

        public void setInProduction(boolean p)

        Is FCM Push configured for production or a dev environment?