Skip to content

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.

  1. The app should call this interface at the specified point and under the specified conditions according to requirements.
  2. This can be called only after this SDK has initialized successfully.
  3. 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.
  4. It is not recommended to call this immediately after the first launch.
  5. If the device version is earlier than Android 13.0, the interface directly returns "granted".
  6. After the user grants authorization, calling this interface again directly returns "granted".
  7. 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 ​

ParameterDescription
contextContext object.
listenerGDNotificationPermissionRequestListener 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");
                    }
                });