1、hook SpringBorad
我們還需要寫兩個頭文件騙過編譯器,并在tweak.xm中導入。
// CLLocationManager.h
@interface CLLocationManager
+(id)sharedManager;
+(BOOL)locationServicesEnabled;
+(void)setLocationServicesEnabled:
(BOOL)enabled;
@end
判斷是否打開定位
[[CLLocationManager sharedManager]locationServicesEnabled]
打開定位
[CLLocationManager setLocationServicesEnabled: YES]
關閉定位
[CLLocationManager setLocationServicesEnabled: NO]