不废话,直接上代码!
ios:
+(void) openURL:(NSString *)url{
//需要注意 url不能带有中文。
NSLog(@"openURL!!!!!");
NSLog(url);
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
//设备系统为IOS 10.0或者以上的
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:nil];
}else{
//设备系统为IOS 10.0以下的
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
}
android:
public void openURL(String url){
final Uri uri = Uri.parse(url);
final Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
}