通过实践,发现ios不同版本调用系统拨打电话调用的方法不同,以ios10.2为界限。
解决方法:代码如下
- (void)kefu:(UIButton *)sender {
NSString *phoneStr =@"tel://";
NSString *str2 = [[UIDevicecurrentDevice] systemVersion];
if ([str2compare:@"10.2"options:NSNumericSearch] ==NSOrderedDescending || [str2compare:@"10.2"options:NSNumericSearch] ==NSOrderedSame)
{
[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:[phoneStr stringByAppendingString:_model.servicephone]]options:@{}completionHandler:^(BOOL success) {
}];
return;
}
[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:[phoneStr stringByAppendingString:_model.servicephone]]];
}
ps: 通过实践,ios8,ios9的版本使用这个方法会直接崩掉。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[phoneStr stringByAppendingString:_model.servicephone]] options:@{} completionHandler:^(BOOLsuccess) {
}];
return;
}