@@ -222,6 +222,8 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central {
222222 case CBManagerStateUnsupported:
223223 self.bluetoothAvailable = false ; break ; // NSLog(@"手机不支持蓝牙功能,请更换手机。");
224224 case CBManagerStatePoweredOff:
225+
226+ [self customAlertOpenBluetooth ];
225227 self.bluetoothAvailable = false ; break ; // NSLog(@"手机蓝牙功能关闭,请前往设置打开蓝牙及控制中心打开蓝牙。");
226228 case CBManagerStateUnauthorized:
227229 self.bluetoothAvailable = false ; break ; // NSLog(@"手机蓝牙功能没有权限,请前往设置。");
@@ -230,4 +232,28 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central {
230232
231233 [self .tableView reloadData ];
232234}
235+
236+ - (void )customAlertOpenBluetooth {
237+ NSDictionary *infoDict = [[NSBundle mainBundle ] infoDictionary ];
238+ NSString *app_Name = [infoDict objectForKey: @" CFBundleDisplayName" ];
239+ if (app_Name == nil ) {
240+ app_Name = [infoDict objectForKey: @" CFBundleName" ];
241+ }
242+
243+ NSString *messageString = [NSString stringWithFormat: NSLocalizedString(@" access_bluetooth_intro" , @" 如未能成功获取蓝牙状态,请尝试前往【设置】-【蓝牙】中开启,为了便于您访问蓝牙设备,因此腾讯连连需获取蓝牙权限" )];
244+ NSString *titleString = [NSString stringWithFormat: @" \" %@ \" %@ " ,app_Name,NSLocalizedString(@" would_lick_access_bluetooth" , @" 想要使用蓝牙" )];
245+ UIAlertController *alertC = [UIAlertController alertControllerWithTitle: titleString message: messageString preferredStyle: (UIAlertControllerStyleAlert)];
246+
247+ UIAlertAction *alertCancel = [UIAlertAction actionWithTitle: NSLocalizedString(@" cancel" , @" 取消" ) style: (UIAlertActionStyleDefault) handler: ^(UIAlertAction * _Nonnull action) {
248+
249+ }];
250+ [alertC addAction: alertCancel];
251+
252+ UIAlertAction *alertConfirm = [UIAlertAction actionWithTitle: NSLocalizedString(@" confirm" , @" 确定" ) style: (UIAlertActionStyleDefault) handler: ^(UIAlertAction * _Nonnull action) {
253+ }];
254+ [alertC addAction: alertConfirm];
255+
256+ [self presentViewController: alertC animated: YES completion: nil ];
257+ }
258+
233259@end
0 commit comments