很多app在開發(fā)過程中,在訪問位置信息瑟俭,相冊,相機(jī)贞瞒,麥克風(fēng)等功能的時(shí)候被用戶拒絕訪問了偶房,下次用戶使用該功能的時(shí)候我們需要提醒用戶去設(shè)置頁面打開該功能。
處理方式如下:
在項(xiàng)目中的info中添加 URL types
添加 URL Schemes 為 prefs的url
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *boundleId = infoDict[@"CFBundleIdentifier"];
NSString*url = [NSString stringWithFormat:@"prefs:root=%@", boundleId];
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]]) {
? ? ? ? [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
效果圖如下: