0

With the playstore requiring the minimumTargetSDK version to be 33, it caused my notification libraries to no longer work with android 13.

Libraries Affected

 1. awesome-cordova-plugins/local-notifications/ngx (Local Notification)

 2. cordova-plugin-fcm-with-dependecy-updated/ionic/ngx (FCM)

Attemped Solution

Added necessary permission in Android Manifest

 <uses-permission android:name="android.permission.NFC" />

Try to request for notification permission to no avail

The former function will return false for requestPermission() without showing the dialog for me to indicate if I want to grant permission to the app.

async askForLocalNotificationPermission() {
    if (this.platform.is('android')) {
      const hasPermission = await this.localNotifications.requestPermission();

      if (hasPermission) {
        console.log('Notification permission granted');
      } else {
        console.log('Notification permission denied');
      }
    }
  }

The latter function will return true for requestPermission() without showing the dialog for me to indicate if I want to grant permission to the app.

async askForFCMNotificationPermission() {
    if (this.platform.is('android')) {
      const hasPermission = await this.fcm.requestPermission();

      if (hasPermission) {
        console.log('Notification permission granted');
      } else {
        console.log('Notification permission denied');
      }
    }
  }
Yeo Bryan
  • 331
  • 4
  • 24

1 Answers1

0
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

Add this permission and request the user to grant the permission at runtime.

Lathesh
  • 340
  • 1
  • 7
  • whats the code to request for notification at run time? I am finding it hard to ask for the permission in typescript as it is an ionic project. Most of the example code is in java/kotlin @Lathesh – Yeo Bryan Aug 29 '23 at 02:07
  • Have you tried this? https://stackoverflow.com/questions/36282191/requesting-permissions-at-run-time-ionic – Lathesh Sep 01 '23 at 07:28