Gamebase SDK for Android 2.44.2
NHN Cloud Gamebase Platform
Loading...
Searching...
No Matches
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:

.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIconName("notification_icon_name")
.build();
Gamebase.Push.registerPush(activity, configuration, options, callback);
This class provides wrapping of function execution related to push notification.
Definition: Gamebase.java:1974
static void registerPush(@NonNull final Activity activity, @NonNull final PushConfiguration pushConfiguration, @NonNull final GamebaseCallback callback)
Register push information to the push server.
Definition: Gamebase.java:2005
static GamebaseNotificationOptions getNotificationOptions(@NonNull final Context context)
Get notification options in device.
Definition: Gamebase.java:2140
This class is a wrapper class that is provided to use various features of Gamebase platform.
Definition: Gamebase.java:59
GamebaseNotificationOptions build()
This method creates an instance of GamebaseNotificationOptions.
Definition: GamebaseNotificationOptions.java:143
Builder enableForeground(boolean foregroundEnabled)
Definition: GamebaseNotificationOptions.java:112
Builder setSmallIconName(String smallIconName)
Definition: GamebaseNotificationOptions.java:127
Builder setPriority(int priority)
Definition: GamebaseNotificationOptions.java:122
Parameter class for the change push options like 'enableForeground'.
Definition: GamebaseNotificationOptions.java:19
static Builder newBuilder()
The factory method to create an instance of the builder to build GamebaseNotificationOptions.
Definition: GamebaseNotificationOptions.java:80
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.
}
});
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.
Definition: Gamebase.java:2168
static boolean isSuccess(@Nullable final GamebaseException exception)
Returns true if the GamebaseException object is null or the error code is zero.
Definition: Gamebase.java:158
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:

@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.
}
}
});
static void queryPush(@NonNull final Activity activity, @NonNull final GamebaseDataCallback< PushConfiguration > callback)
Get push settings from the the push server.
Definition: Gamebase.java:2082
An object that contains the success or failure of the execution of the Gamebase function.
Definition: GamebaseException.java:26
Parameter class for the initialization of the GamebaseToastPushable#registerToken(Activity,...
Definition: PushConfiguration.java:27
boolean adAgreementNight
Definition: PushConfiguration.java:35
boolean adAgreement
Definition: PushConfiguration.java:34
boolean pushEnabled
Definition: PushConfiguration.java:33
Generic callback interface that returns data.
Definition: GamebaseDataCallback.java:12
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:

@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.
}
}
});
static void queryTokenInfo(@NonNull final Activity activity, @NonNull final GamebaseDataCallback< GamebasePushTokenInfo > callback)
Get push settings from the the push server.
Definition: Gamebase.java:2115
final boolean adAgreementNight
Definition: GamebasePushAgreement.java:13
final boolean adAgreement
Definition: GamebasePushAgreement.java:12
final boolean pushEnabled
Definition: GamebasePushAgreement.java:11
final GamebasePushAgreement agreement
Definition: GamebasePushTokenInfo.java:29
final String token
Definition: GamebasePushTokenInfo.java:17
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:

.enablePush(true)
.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.
}
}
});
Builder enablePush(boolean pushEnabled)
Definition: PushConfiguration.java:231
Builder enableAdAgreement(boolean adAgreement)
Definition: PushConfiguration.java:236
Builder enableAdAgreementNight(boolean adAgreementNight)
Definition: PushConfiguration.java:241
PushConfiguration build()
This method creates an instance of PushConfiguration.
Definition: PushConfiguration.java:272
static Builder newBuilder()
The factory method to create an instance of the builder to build PushConfiguration.
Definition: PushConfiguration.java:104
Definition: GamebaseCallback.java:9
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:

.enablePush(true)
.build();
.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.