uniapp Andrews judge notification permission (and set to jump by version)

var main = plus.android.runtimeMainActivity ();
 var pkName = main.getPackageName ();
 var UID = main.getApplicationInfo () plusGetAttribute ( "UID." );
 var NotificationManagerCompat = plus.android.importClass ( "android.support. v4.app.NotificationManagerCompat " );
 var areNotificationsEnabled = NotificationManagerCompat.from (main) .areNotificationsEnabled ();
 // not activated 'permission notice' rights, the reminder pop open, and click confirmation page to jump to the system settings set   
IF (! areNotificationsEnabled) {
  uni.showModal({
    title: 'prompt' ,  
    Content: 'Please open the APP notification authority' ,  
    showCancel: false,  
    success: function (res) {  
      if (res.confirm) {  
        var Intent = plus.android.importClass('android.content.Intent');
        var Build = plus.android.importClass("android.os.Build");
        //android 8.0引导  
        if (Build.VERSION.SDK_INT >= 26) {
          var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
          intent.putExtra('android.provider.extra.APP_PACKAGE', pkName);
        } else if (Build.VERSION.SDK_INT >= 21) { //android 5.0-7.0  
          var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
          intent.putExtra("app_package", pkName);
          intent.putExtra("app_uid", uid);
        } The else { // (<21 is) Other - jumps to the application management details page 
          var Settings = plus.android.importClass ( "android.provider.Settings" );
           var Uri = plus.android.importClass ( "Android .net.Uri " );
           var Intent = new new the Intent ();
          intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
          var uri = Uri.fromParts("package", main.getPackageName(), null);
          intent.setData(uri);
        }
        // Go to the application of the system notification settings page   
        main.startActivity (intent);
      }  
    }
  });
}

 

Guess you like

Origin www.cnblogs.com/Stalker24/p/12510672.html