似乎Apple正在逐渐摆脱通过链接打开应用程序的自定义方案机制 .使用自定义方案,如果您尝试打开应用程序注册的自定义方案,应用程序将打开,javascript函数handleOpenURL将处理该调用 .
worklight是否支持IOS9中新的“通用链接”方法?
Universal Linking未作为iOS 9支持的一部分进行测试 . 如果需要链接,请暂时继续使用自定义方案选项 .
编辑:测试并发现工作 .
在我们的项目中,worklight没有触发开启即用的Universal Links功能的handleOpenURL功能 .
所以,我们使用了以下解决方案:
1)原生图层插件
MyAppDelegate UniversalLinksPlugin.h
#import "rr.h" @interface MyAppDelegate (UniversalLinksPlugin) - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler; @end
MyAppDelegate UniversalLinksPlugin.m
#import "rr.h" #import <objc/runtime.h> @implementation MyAppDelegate (UniversalLinksPlugin) - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler { NSLog(@"Universal links plugin: starting application launch handling."); // ignore activities that are not for Universal Links if (![userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb] || userActivity.webpageURL == nil) { return NO; } NSString* url = [userActivity.webpageURL absoluteString]; NSLog(@"Universal links plugin: the following url is used for the application launch %@", url); NSMutableDictionary *data = [[NSMutableDictionary alloc] init]; [data setValue:url forKey:@"url"]; [[WL sharedInstance] sendActionToJS:@"handleURL" withData:data]; return YES; } @end
2)config.xml更新:
<feature name="UniversalLinksPlugin"> <param name="ios-package" value="UniversalLinksPlugin"/> </feature>
3)iphone / js / main.js更新:
/** * UL links handling */ document.addEventListener("deviceready", function() { WL.App.addActionReceiver ("ULReceiver", function(received) { if (received.action === "handleURL") { WL.Logger.debug('Inside handle URL action receiver. Provided url: ' + received.data.url); handleOpenURL(received.data.url); } }); }, false);
就是这个 . 我真的希望这对某人有帮助)
2 回答
Universal Linking未作为iOS 9支持的一部分进行测试 . 如果需要链接,请暂时继续使用自定义方案选项 .
编辑:测试并发现工作 .
在我们的项目中,worklight没有触发开启即用的Universal Links功能的handleOpenURL功能 .
所以,我们使用了以下解决方案:
1)原生图层插件
MyAppDelegate UniversalLinksPlugin.h
MyAppDelegate UniversalLinksPlugin.m
2)config.xml更新:
3)iphone / js / main.js更新:
就是这个 . 我真的希望这对某人有帮助)