iOS的URLScheme
来源:互联网 发布:落叶能知易水寒下句 编辑:程序博客网 时间:2024/06/05 05:41
如何在info.plist中加入url scheme
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.xxxx.xxxx</string>
<key>CFBundleURLSchemes</key>
<array>
<string>yourURLScheme</string>
</array>
</dict>
</array>
直接在xCode中操作添加URL Types
- 不要实现applicationDidFinishLaun
ching: 方法 - 实现application:didFinishLaunchingWithOp
tions: 方法,并在其中检查url,如果能处理该url则返回YES,否则不做处理返回NO。 - 实现application:handleOpenURL:,处理url,成功返回YES,否则返回NO。
- 如果是启动程序,则application:didFinishLaunchingWithOp
tions: 被执行,返回YES当且仅当application:handleOpenURL:执行返回YES。 - 如果程序由后台挂起变为活动,则application:didFinishLaunchingWithOp
tions: 不会被执行,但是application:handleOpenURL:会被执行。
-( BOOL)application:(UIApplication*)application handleOpenURL:(NSURL *)url {
NSLog(@"%@", [url absoluteString]);
if ([[url host] isEqualToString:@"yourURLScheme"]) {
return YES;
}
return NO;
}
-( BOOL)application:(UIApplication*)application didFinishLaunchingWithOp tions: (NSDictionary*)launchOptions {
...
NSURL *url = ( NSURL*)[launchOptions valueForKey:UIApplicationLaunchOptio nsURLKey ];
if ([self application:application handleOpenURL:url]) {
return YES;
}
return NO;
}// End of application:didFinishLaunchingWithOp tions:
注意:
-( BOOL)application:(UIApplication*)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<script>
window.location= "URL Scheme:";
setTimeout(function(){ window.location="http://App Store地址"; } , 1500);
</script>
</body>
</html>
代码如何调用
NSURL *url = [NSURL URLWithString:@"URL Scheme://"];
[[UIApplicationsharedApplication] openURL:url];
0 0
- iOS的URLScheme
- UrlScheme让别人可以打开我们的应用
- urlscheme白名单问题以及项目适配iOS9遇到的一些问题及解决办法
- Citrix Receiver URLScheme
- iOS9 URLScheme白名单
- iOS9-URLScheme适配-引入白名单概念
- [iOS] ios的runtime
- [iOS] ios的runtime
- [iOS] ios的runtime
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- [iOS] iOS 6的Rotation
- IOS的乱七八糟的
- Kafka详解五、Kafka Consumer的底层API- SimpleConsumer
- java笔记-高新技术-反射
- 编程之美--最大公约数问题
- qt-opengl 初学的一个简单的程序
- Java导出最近更新的.class文件(包含目录结构)
- iOS的URLScheme
- hdu 2349 最小生成树
- 【Tools】Excel数据透视表 PivotTable
- 网络硬时间戳在何时何地打的?
- ORACLE 存储过程被锁,编译不了问题
- Android动画之Interpolator插补器
- jQuery和Prototype的兼容性和冲突的五种解决方法
- Linux内核驱动GPIO的使用
- ArcGIS 教程:Spatial Analyst扩展模块中的分析