Push Permission Request
Devices running Android 13.0 (API 33) or later require user authorization for push notification permissions before the app can display push notifications.
- The app should call this interface at the specified point and under the specified conditions according to requirements.
- This can be called only after this SDK has initialized successfully.
- It is recommended that the game call this after the beginner flow ends or after another point where the user has had a good game experience, to increase the user's willingness to grant authorization.
- It is not recommended to call this immediately after the first launch.
- If the device version is earlier than Android 13.0, the interface directly returns "granted".
- After the user grants authorization, calling this interface again directly returns "granted".
- During a single app installation, if this interface is called multiple times and the user rejects authorization each time, the interface directly returns "declined" and no authorization prompt dialog is displayed again.
Function
java
GDSDK.gamedreamerNotificationPermissionRequest(Context context, GDNotificationPermissionRequestListener listener)Parameters
| Parameter | Description |
|---|---|
| context | Context object. |
| listener | GDNotificationPermissionRequestListener callback listener. |
onGranted Callback Description
GDNotificationPermissionRequestListener.onGranted() Callback Method Description
Case 1: The calling device version is < Android 13.0 (API 33). Case 2: The first call, and the user grants notification permission. Case 3: A non-first call, and the user has previously granted notification permission.
onDeclined Callback Description
GDNotificationPermissionRequestListener.onDeclined() Callback Method Description
The calling device version is >= Android 13.0 (API 33), and the user rejects push notification permission.
Example Code
java
GDSDK.gamedreamerNotificationPermissionRequest(this, new GDNotificationPermissionRequestListener() {
@Override
public void onGranted() {
simpleToast("Granted");
}
@Override
public void onDeclined() {
simpleToast("Declined");
}
});