#import "AppDelegate.h"
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate () <CLLocationManagerDelegate>
@property (strong, nonatomic) CLLocationManager *manager;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIUserNotificationType type = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
_manager = [[CLLocationManager alloc] init];
_manager.delegate = self;
[_manager requestAlwaysAuthorization];
return YES;
}
#pragma mark - CLLocationManagerDelegate
@end
#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
NSLog(@"点击了");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"欢迎召召, 请上3楼!";
notification.region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(23.133916, 113.395557) radius:500 identifier:@"YunShuiYao"];
notification.regionTriggersOnce = NO;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
@end