utils.js 1.1 KB

123456789101112131415161718192021222324
  1. const gotoAppPermissionSetting = function() {
  2. if (plus.os.name === 'iOS') {
  3. var UIApplication = plus.ios.import('UIApplication');
  4. var application2 = UIApplication.sharedApplication();
  5. var NSURL2 = plus.ios.import('NSURL');
  6. var setting2 = NSURL2.URLWithString('app-settings:');
  7. application2.openURL(setting2);
  8. plus.ios.deleteObject(setting2);
  9. plus.ios.deleteObject(NSURL2);
  10. plus.ios.deleteObject(application2);
  11. } else {
  12. var Intent = plus.android.importClass('android.content.Intent');
  13. var Settings = plus.android.importClass('android.provider.Settings');
  14. var Uri = plus.android.importClass('android.net.Uri');
  15. var mainActivity = plus.android.runtimeMainActivity();
  16. var intent = new Intent();
  17. intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  18. var uri = Uri.fromParts('package', mainActivity.getPackageName(), null);
  19. intent.setData(uri);
  20. mainActivity.startActivity(intent);
  21. }
  22. };
  23. export default gotoAppPermissionSetting;