Gamebase SDK for Android  2.39.0
NHN Cloud Gamebase Platform
Gamebase.Push Class Reference

This class provides wrapping of function execution related to push notification. More...

Collaboration diagram for Gamebase.Push:
Collaboration graph

Static Public Member Functions

static void registerPush (@NonNull final Activity activity, @NonNull final PushConfiguration pushConfiguration, @NonNull final GamebaseCallback callback)
 Register push information to the push server. More...
 
static void registerPush (@NonNull final Activity activity, @NonNull final PushConfiguration pushConfiguration, @NonNull final GamebaseNotificationOptions notificationOptions, @NonNull final GamebaseCallback callback)
 Register push information to the push server. More...
 
static void queryPush (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< PushConfiguration > callback)
 Get push settings from the the push server. More...
 
static void queryTokenInfo (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< GamebasePushTokenInfo > callback)
 Get push settings from the the push server. More...
 
static GamebaseNotificationOptions getNotificationOptions (@NonNull final Context context)
 Get notification options in device. More...
 
static void queryNotificationAllowed (@NonNull final Context context, @NonNull final GamebaseDataCallback< Boolean > callback)
 This API tells that the user has allowed the device to display notification. More...
 

Detailed Description

This class provides wrapping of function execution related to push notification.

Member Function Documentation

◆ getNotificationOptions()

static GamebaseNotificationOptions getNotificationOptions ( @NonNull final Context  context)
static

Get notification options in device.

Since
Added 2.15.0.
Parameters
contextApplication context. The activity is OK, too.
Returns
The option settings of device notification.

Example Usage:

GamebaseNotificationOptions currentOptions = Gamebase.Push.getNotificationOptions(activity);
GamebaseNotificationOptions options = GamebaseNotificationOptions.newBuilder(currentOptions)
.enableForeground(true)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIconName("notification_icon_name")
.build();
Gamebase.Push.registerPush(activity, configuration, options, callback);
See also
com.toast.android.gamebase.base.push.data.GamebaseNotificationOptions.

◆ queryNotificationAllowed()

static void queryNotificationAllowed ( @NonNull final Context  context,
@NonNull final GamebaseDataCallback< Boolean >  callback 
)
static

This API tells that the user has allowed the device to display notification.

Since
Added 2.34.0.
Parameters
contextApplication context. The activity is OK, too.
callbackThe result.

Example Usage:

Gamebase.Push.queryNotificationAllowed(context, (isAllowed, exception) -> {
if (Gamebase.isSuccess(exception)) {
if (isAllowed) {
// The user allowed notification.
} else {
// The user blocked notification.
}
} else {
// Failed to check device setting.
}
});
See also
com.toast.android.gamebase.GamebaseDataCallback.

◆ queryPush()

static void queryPush ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< PushConfiguration callback 
)
static

Get push settings from the the push server.

This is legacy push API. We recommend to use the new API Push#queryTokenInfo(Activity, GamebaseDataCallback).

Since
Added 1.4.0.
Parameters
activityCurrent activity.
callbackCallback pass to API result.

Example Usage:

Gamebase.Push.queryPush(activity, new GamebaseDataCallback<PushConfiguration>() {
@Override
public void onCallback(PushConfiguration data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// Query push succeeded.
boolean enabledPush = data.pushEnabled;
boolean enabledAdPush = data.adAgreement;
boolean enabledAdPushNight = data.adAgreementNight;
} else {
// Query push failed.
}
}
});
See also
PushConfiguration.
com.toast.android.gamebase.GamebaseDataCallback.

◆ queryTokenInfo()

static void queryTokenInfo ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< GamebasePushTokenInfo callback 
)
static

Get push settings from the the push server.

Since
Added 2.15.0.
Parameters
activityCurrent activity.
callbackCallback pass to API result.

Example Usage:

Gamebase.Push.queryTokenInfo(activity, new GamebaseDataCallback<GamebasePushTokenInfo>() {
@Override
public void onCallback(GamebasePushTokenInfo data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// Query push token info succeeded.
String token = data.token;
boolean enabledPush = data.agreement.pushEnabled;
boolean enabledAdPush = data.agreement.adAgreement;
boolean enabledAdPushNight = data.agreement.adAgreementNight;
} else {
// Query push token info failed.
}
}
});
See also
com.toast.android.gamebase.base.push.data.GamebasePushTokenInfo.
com.toast.android.gamebase.GamebaseDataCallback.

◆ registerPush() [1/2]

static void registerPush ( @NonNull final Activity  activity,
@NonNull final PushConfiguration  pushConfiguration,
@NonNull final GamebaseCallback  callback 
)
static

Register push information to the push server.

Since
Added 1.4.0.
Parameters
activityCurrent activity.
pushConfigurationSettings of the push from server.
callbackCallback pass to API result.

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.
}
}
});
See also
PushConfiguration.
com.toast.android.gamebase.GamebaseCallback.

◆ registerPush() [2/2]

static void registerPush ( @NonNull final Activity  activity,
@NonNull final PushConfiguration  pushConfiguration,
@NonNull final GamebaseNotificationOptions  notificationOptions,
@NonNull final GamebaseCallback  callback 
)
static

Register push information to the push server.

Since
Added 2.15.0.
Parameters
activityCurrent activity.
pushConfigurationSettings of the push from server.
notificationOptionsSettings of the local notification.
callbackCallback pass to API result.

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.
}
}
});
See also
PushConfiguration.
com.toast.android.gamebase.GamebaseCallback.