零碎知识整理-外链应用

part1:URI方式跳转应用外地图类应用导航

功能:首先获取该设备支持应用外地图类应用的列表->传入该应用的对应的接口参数,实现跳转->(若支持回跳转,在应用类传入相应的接口参数跳转回来)。

实现:1.首先获取支持跳转的地图应用列表:

if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"http://maps.apple.com/"]]){
      //苹果地图...
    }
if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]){
        //百度地图...
    }
if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
        //高德地图...
    }

2.查找各个跳转应用的api接口要求和协议格式,如高德:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择地图" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *action = [UIAlertAction actionWithTitle:@"高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            
            NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",appName,urlScheme,coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];   }];
        
        [alert addAction:action];}

3.这个是跳转到地图类应用的导航类功能,因此部分应用如高德和google支持跳转后,回跳回原应用。一般都是通过一开始跳转的时候传入的接口来判断结束导航后跳转该原应用而实现跳转。

转载于:https://www.cnblogs.com/ramboback/p/4735908.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值