# registerPush

open fun registerPush(@NonNull activity: Activity, @NonNull pushConfiguration: PushConfiguration, @NonNull callback: GamebaseCallback)

Register push information to the push server.

Example Usage:

    PushConfiguration configuration = PushConfiguration.newBuilder()
            .enablePush(true)
            .enableAdAgreement(true)
            .enableAdAgreementNight(false)
            .build();
    Gamebase.Push.registerPush(activity, configuration, new GamebaseCallback() {
        @Override
        public void onCallback(GamebaseException exception) {
            if (Gamebase.isSuccess(exception)) {
                // Register push succeeded.
            } else {
                // Register push failed.
            }
        }
    });

Content copied to clipboard

#### Since

Added 1.4.0.

#### Parameters

activity

Current activity.

pushConfiguration

Settings of the push from server.

callback

Callback pass to API result.

#### See also

PushConfiguration
GamebaseCallback

open fun registerPush(@NonNull activity: Activity, @NonNull pushConfiguration: PushConfiguration, @NonNull notificationOptions: GamebaseNotificationOptions, @NonNull callback: GamebaseCallback)

Register push information to the push server.

Example Usage:

    PushConfiguration configuration = PushConfiguration.newBuilder()
            .enablePush(true)
            .build();
    GamebaseNotificationOptions currentOptions = Gamebase.Push.getNotificationOptions(activity);
    GamebaseNotificationOptions options = GamebaseNotificationOptions.newBuilder(currentOptions)
            .enableForeground(true)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .build();
    Gamebase.Push.registerPush(activity, configuration, options, new GamebaseCallback() {
        @Override
        public void onCallback(GamebaseException exception) {
            if (Gamebase.isSuccess(exception)) {
                // Register push succeeded.
            } else {
                // Register push failed.
            }
        }
    });

Content copied to clipboard

#### Since

Added 2.15.0.

#### Parameters

activity

Current activity.

pushConfiguration

Settings of the push from server.

notificationOptions

Settings of the local notification.

callback

Callback pass to API result.

#### See also

PushConfiguration
GamebaseCallback