应用程序间跳转的应用场景

  1. 使用第三方用户登录,如微信登录,返回用户名和密码
  2. 需要用户授权,返回到调用程序,同时返回授权的用户名
  3. 应用程序推广,跳转到itunes并显示指定app下载页
  4. 第三方支付,跳转到支付APP,如支付宝,微信钱包
  5. 显示位置及导航功能时,跳转到第三方地图应用。
  6. 打电话、发邮件、发短信、打开网页等,跳转到内置APP程序

应用间的跳转:

1.//url :统一资源占位符 http://baidu.com tel://110 file:///apple/storebock

//由    协议头:http:// tel:// file://

//     资源路径:baidu.com

2.如何配置应用程序的URL的协议头: target (项目)- > info > URL Type >URL Schemes

3.APP —A

//跳转到微信APP

- (IBAction)jump {

[self openXiaodiWeiXin:@"xiaodi://"];

}

//跳转到微信好友界面,带上另一个要跳转到的控制器的indentify和自己的Schemes(协议头)

- (IBAction)secttion {

[self openXiaodiWeiXin:@"xiaodi://secttion?Schemes=news"];

}

//跳转到朋友圈界面

- (IBAction)timeLine {

[self openXiaodiWeiXin:@"xiaodi://timeLine"];

}

-(void)openXiaodiWeiXin:(NSString *)URLStr

{

//2.如何配置应用程序的URL的协议头: target (项目)- > info > URL Type >URL Schemes

//1.创建要跳转的应用程序的URL

NSURL *weixinURL = [NSURL URLWithString:URLStr];

//2.判断URL是否可以跳转

if ([[UIApplication sharedApplication]canOpenURL:weixinURL]) {

//跳转到另一个应用程序

[[UIApplication sharedApplication]openURL:weixinURL];

}

}

****************

APP — B

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

{

UINavigationController *nav = (UINavigationController *)self.window.rootViewController;

//消除动画,会先把当前的控制器压栈,返回会先返回原来的控制器,再返回主页

[nav popToRootViewControllerAnimated:NO];

ViewController *mainVC = [nav.childViewControllers firstObject];

NSString *urlStr = url.absoluteString;

if ([urlStr rangeOfString:@"secttion" ].length) {

//把传过来的Schemes 传到相应控制器(方便跳回原来的APP)

mainVC.appURLStr = urlStr;

//跳转到相应的控制器

[mainVC performSegueWithIdentifier:@"Secction" sender:nil];

NSLog(@"这是通过微信好友打开:%@",url);

}else if ([urlStr rangeOfString:@"timeLine"].length)

{

//跳转到相应的控制器

[mainVC performSegueWithIdentifier:@"TimeLine" sender:nil];

NSLog(@"这是通过微信朋友圈打开的%@",url);

}

return YES;

}

****ViewController.m

//使用UIStoryboardSegue 话,可以利用该方法传值

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{

if ([segue.identifier isEqualToString:@"Secction"]) {

SecttionViewController *secttionVC =  segue.destinationViewController;

secttionVC.appURLStr = self.appURLStr;

}

}

****相应要跳转的页面实现跳回原来的APP

/回到原来的APP

- (IBAction)BackToApp {

NSString *urlStr = self.appURLStr;

NSRange rangstring =[urlStr rangeOfString:@"xiaodi://secttion?Schemes="];//NSRangeFromString()

NSString *schemesStr =  [urlStr substringFromIndex: rangstring.length];

NSLog(@"%@",schemesStr);

NSString *schemesString = [NSString stringWithFormat:@"%@://",schemesStr];

NSURL *schemesUrl =[NSURL URLWithString:schemesString];

if ([[UIApplication sharedApplication]canOpenURL:schemesUrl]) {

[[UIApplication sharedApplication]openURL:schemesUrl];

}

}

//****************************************************

1.利用系统自带做分享 (看工程 友盟分享)

//1.测试平台是否可用

if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) {

NSLog(@"新浪微博分享是否成功,如果没有 请 设置界面 》新浪微博 》 设置新浪微博ID ");

}

//2.创建SLComposeViewController

SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];

//设置发送的文字

[composeViewController setInitialText:@"千年等一回,不要错过"];

//设置发送的图片

[composeViewController  addImage:[UIImage imageNamed:@"SSO"]];

//弹出发送界面

[self presentViewController:composeViewController animated:YES completion:nil];

//设置分享成功与取消的提醒

composeViewController.completionHandler = ^(SLComposeViewControllerResult result)

{

if (result == SLComposeViewControllerResultCancelled) {

NSLog(@"用户取消了分享");

}else

{

NSLog(@"用户点击了发送");

}

};

友盟SSO授权分享:

什么是SSO的授权方式呢?

大家常说的SSO的授权方式,其实全称是Single Sign-On,就是利用新浪微博、QQ空间、手机QQFacebook客户端来完成授权。对于用户来说可以省去输入账号密码,更方便安全,因此各大平台均建议开发者优先使用这一种授权方式。ShareSDK目前支持以下平台的SSO:新浪微博、腾讯微博、QQ空间、facebook、Pocket.

网址:http://dev.umeng.com/social/android/operation

当要用很自己手机的已经安装的软件进行分享某篇文章图片小视屏等等都可以使用

最新文章

  1. 处理Https 异常记录 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
  2. 移动开发下Xamarin VS PhoneGap
  3. C语言 数组之无限循环
  4. linux下syscall函数,SYS_gettid,SYS_tgkill
  5. Improving the GPA 分类: 贪心 HDU 比赛 2015-08-08 16:12 11人阅读 评论(0) 收藏
  6. C#全角和半角转换
  7. [quote ]ffmpeg, gstreamer, Raspberry Pi, Windows Desktop streaming
  8. UNIX标准化及实现之选项
  9. jquery.validate.js默认配置,jquery.validate.js自定义提示信息
  10. java web中jsp连接mysql数据库 以及数据库连接池的使用
  11. C语言 一维数组叠加为二维数组样例
  12. iOS开发中frame与bounds的区别
  13. 聊一聊Redis的数据结构
  14. linux无密码连接
  15. sudo用法
  16. iOS中 加强日志输出 开发技术总结
  17. 承上 DBlink 与 SCN | 新增视图找出外部 SCN 跳变
  18. lastIndexOf() 找出指定元素出现的所有位置(返回的是下标数组)---lastIndexOf() 这个方法是倒叙查找,正序的是indexOf()
  19. 今天看到了一篇文档 app 测试内容记录下来
  20. SQl查询数据库库名,表名、表的列名

热门文章

  1. probe函数何时调用的
  2. 图结构练习——最小生成树(prim算法(普里姆))
  3. 2014百度之星资格赛 1001:Energy Conversion(水题,逻辑题)
  4. RAC NTP/CTSS
  5. [Spring Batch] 图解Spring Batch原理
  6. OpenMesh 之向量操作
  7. 同一天的时间差,显示为HHMMSS和指定日期时间部分
  8. Axure 全局辅助线(转)
  9. JAVA的容器---List,Map,Set (转)
  10. loj 1099(最短路)