|
|
@@ -17,6 +17,7 @@
|
|
|
#import "RAHomeHeaderView.h"
|
|
|
#import "RAMessageViewController.h"
|
|
|
#import "RASettingViewController.h"
|
|
|
+#import <CoreLocation/CoreLocation.h>
|
|
|
|
|
|
@implementation RAHomeSectionModel
|
|
|
|
|
|
@@ -94,6 +95,8 @@
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
|
+ [self checkPermission];
|
|
|
+
|
|
|
[self configureNavigationBar];
|
|
|
[self configureTable];
|
|
|
[self registNotification];
|
|
|
@@ -181,6 +184,54 @@
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveReloadNotification:) name:RANotificationReloadHome object:nil];
|
|
|
}
|
|
|
|
|
|
+- (void)checkPermission {
|
|
|
+
|
|
|
+ CLAuthorizationStatus locationAuthoriztionAstatus = [CLLocationManager authorizationStatus];
|
|
|
+ [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
|
|
+
|
|
|
+ UNAuthorizationStatus notificationAuthorizationStatus = settings.authorizationStatus;
|
|
|
+
|
|
|
+ BOOL enableLocation = locationAuthoriztionAstatus != kCLAuthorizationStatusRestricted && locationAuthoriztionAstatus != kCLAuthorizationStatusDenied;
|
|
|
+ BOOL enableRemoteNotification = notificationAuthorizationStatus != UNAuthorizationStatusDenied;
|
|
|
+
|
|
|
+ if (!enableLocation | !enableRemoteNotification) {
|
|
|
+
|
|
|
+ NSMutableString *msg = [NSMutableString stringWithString:@"you should open"];
|
|
|
+
|
|
|
+ if (!enableLocation) {
|
|
|
+ [msg appendString:@" location permissions"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!enableRemoteNotification) {
|
|
|
+
|
|
|
+ if (!enableLocation) {
|
|
|
+ [msg appendString:@" and notification permissions"];
|
|
|
+ } else {
|
|
|
+ [msg appendString:@" notification permissions"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+
|
|
|
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
|
|
+ if ([[UIApplication sharedApplication]canOpenURL:url]) {
|
|
|
+ [[UIApplication sharedApplication]openURL:url];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+ [alertVC addAction:okAction];
|
|
|
+
|
|
|
+ [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Action
|
|
|
|
|
|
- (void)uploadListItemClick:(UIBarButtonItem *)sender {
|