Browse Source

added background refresh status

Yonah Forst 8 years ago
parent
commit
9733cc6278
3 changed files with 23 additions and 2 deletions
  1. 3
    1
      README.md
  2. 19
    0
      ReactNativePermissions.m
  3. 1
    1
      package.json

+ 3
- 1
README.md View File

@@ -59,9 +59,11 @@ As shown in the example, methods return a promise with the authorization status
59 59
 
60 60
 `notificationPermissionStatus()` - checks if the user has authorized remote push notifications. Note: Apple only tells us if notifications are authorized or not, not the exact status. So this promise only returns `StatusUndetermined` or `StatusAuthorized`. You can determine if `StatusUndetermined` is actually `StatusRejected` by keeping track of whether or not you've already asked the user for permission.
61 61
 
62
+`backgroundRefreshStatus()` - checks the authorization status of background refresh
63
+
62 64
 
63 65
 You also can open the Settings app.
64
-`openSettings()` - open the Settings app
66
+`openSettings()` - open the Settings app. Note: this is only supported in ios >= 8. You can use `canOpenSettings()` to determine if it's supported.
65 67
 
66 68
 ##Setup
67 69
 

+ 19
- 0
ReactNativePermissions.m View File

@@ -281,5 +281,24 @@ RCT_REMAP_METHOD(notificationPermissionStatus, notificationPermission:(RCTPromis
281 281
     }
282 282
 }
283 283
 
284
+RCT_REMAP_METHOD(backgroundRefreshStatus, backgroundRefresh:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
285
+{
286
+    int status = [[UIApplication sharedApplication] backgroundRefreshStatus];
287
+    
288
+    switch (status) {
289
+        case UIBackgroundRefreshStatusAvailable:
290
+            return resolve(@(RNPermissionsStatusAuthorized));
291
+            
292
+        case UIBackgroundRefreshStatusDenied:
293
+            return resolve(@(RNPermissionsStatusDenied));
294
+            
295
+        case UIBackgroundRefreshStatusRestricted:
296
+            return resolve(@(RNPermissionsStatusRestricted));
297
+            
298
+        default:
299
+            return resolve(@(RNPermissionsStatusUndetermined));
300
+    }
301
+    
302
+}
284 303
 
285 304
 @end

+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-permissions",
3
-  "version": "0.0.3",
3
+  "version": "0.0.4",
4 4
   "repository": {
5 5
     "type": "git",
6 6
     "url": "https://github.com/joshblour/react-native-permissions.git"