@nativescript-community/perms
Advanced tools
Comparing version 2.2.9 to 2.2.11
@@ -6,2 +6,18 @@ # Change Log | ||
## [2.2.11](https://github.com/nativescript-community/perms/compare/v2.2.9...v2.2.11) (2022-07-11) | ||
**Note:** Version bump only for package @nativescript-community/perms | ||
## [2.2.10](https://github.com/nativescript-community/perms/compare/v2.2.9...v2.2.10) (2022-07-11) | ||
**Note:** Version bump only for package @nativescript-community/perms | ||
## [2.2.9](https://github.com/nativescript-community/perms/compare/v2.2.8...v2.2.9) (2022-07-01) | ||
@@ -8,0 +24,0 @@ |
{ | ||
"name": "@nativescript-community/perms", | ||
"version": "2.2.9", | ||
"version": "2.2.11", | ||
"description": "An unified permissions API for NativeScript on iOS and Android.", | ||
@@ -35,3 +35,3 @@ "main": "./permissions", | ||
"readmeFilename": "README.md", | ||
"gitHead": "6e20f6326456d4dd047642722bc206411c3b3fec" | ||
"gitHead": "161c59d9c64098a128453d2ffbdcc8276624beb2" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Device, Trace } from '@nativescript/core'; | ||
import { Device, Trace, Utils } from '@nativescript/core'; | ||
import { CLog, CLogTypes } from './permissions.common'; | ||
@@ -454,32 +454,30 @@ export * from './permissions.common'; | ||
if (status[0] === Status.Undetermined || status[0] === Status.Denied) { | ||
return new Promise((resolve, reject) => { | ||
const observer = function () { | ||
resolve(getStatus()); | ||
NSNotificationCenter.defaultCenter.removeObserver(observer); | ||
}; | ||
NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(UIApplicationDidBecomeActiveNotification, null, null, observer); | ||
const osVersion = parseFloat(Device.osVersion); | ||
if (osVersion >= 10) { | ||
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptionsCompletionHandler(types, (p1, error) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
UIApplication.sharedApplication.registerForRemoteNotifications(); | ||
NSUserDefaults.standardUserDefaults.setBoolForKey(true, NSPDidAskForNotification); | ||
NSUserDefaults.standardUserDefaults.synchronize(); | ||
} | ||
}); | ||
} | ||
else { | ||
const settings = UIUserNotificationSettings.settingsForTypesCategories(types, null); | ||
UIApplication.sharedApplication.registerUserNotificationSettings(settings); | ||
UIApplication.sharedApplication.registerForRemoteNotifications(); | ||
NSUserDefaults.standardUserDefaults.setBoolForKey(true, NSPDidAskForNotification); | ||
NSUserDefaults.standardUserDefaults.synchronize(); | ||
} | ||
await new Promise((resolve, reject) => { | ||
Utils.dispatchToMainThread(() => { | ||
const osVersion = parseFloat(Device.osVersion); | ||
if (osVersion >= 10) { | ||
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptionsCompletionHandler(types, (p1, error) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
UIApplication.sharedApplication.registerForRemoteNotifications(); | ||
resolve(); | ||
} | ||
}); | ||
} | ||
else { | ||
const settings = UIUserNotificationSettings.settingsForTypesCategories(types, null); | ||
UIApplication.sharedApplication.registerUserNotificationSettings(settings); | ||
UIApplication.sharedApplication.registerForRemoteNotifications(); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
NSUserDefaults.standardUserDefaults.setBoolForKey(true, NSPDidAskForNotification); | ||
NSUserDefaults.standardUserDefaults.synchronize(); | ||
return getStatus(); | ||
} | ||
else { | ||
return Promise.resolve(status); | ||
return status; | ||
} | ||
@@ -486,0 +484,0 @@ } |
Sorry, the diff of this file is not supported yet
117424
1285