DeepLink 设置及测试方式
本文档介绍在应用内设置与网页游览器 "myapp://" 上的 Deep Link URL 相同。可以达到直接启动应用的效果。
为了正常使用 IGAWorks 服务上的 DeepLink 功能,请确认如下各内容。
iOS Deep Link Settings
为了在 iOS 应用上设置 DeepLink 功能,请在修改应用上的 info.plist 文件。
- 在 Xcode Project 中打开 Info panel。
- 在 URL types 项目上添加 URL Schemes。
- 还未决定 scheme 值的情况,可可以使用 adbrix 上发布的 App Key。
若 Scheme 值决定为 adbrix 123456 的话,像如下进行修改。
DeepLink 运行测试
按照如下步骤,可以确认 DeepLink 是否正常设置。
- 上述 DeepLink 内容适用后进行打包,并安装及启动。
- 启动设备上或模拟器的 Safari 游览器。
- 在游览器中输入 Scheme 值。按照上述示例设置 Scheme 值时,在 [URL] 中输入 adbrix123456://
成功启动应用时,说明 DeepLink 设置正常。
DeepLink Open Tracking
通过已设置的 DeepLink 内容,用 DeepLink Tracking Link 可以开启应用。
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
[IgaworksCore passOpenURL:url];
return YES;
}
#else
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options
{
[IgaworksCore passOpenURL:url];
return YES;
}
#endif
adbrix Facebook 广告设置 : iOS & Unity iOS
此文档是在 adbrix 中设置 Facebook Mobile App 启动(MAIA)、Mobile App 参加(MAEA) 广告 的集成指南。
*注意事项
- 为了使用此功能,必须先完成 IGAW 共同事项。 [IGAW 共同集成 : iOS] [IGAW 共同集成 : Unity iOS]
- 为了使用 Facebook 广告跟踪功能,SDK 版本需在 IgaworksCore ver 2.2.2 以上。
- 为了使用此功能,需要登录 IDFA 内容。[IGAW Apple IDFA 登录 : iOS] [IGAW Apple IDFA 登录 : Unity iOS]
在 IgaworksCore 2.2.2 版本上添加同时使用 Facebook SDK 的接入方式。
#情况 1. 不集成 FaceBook SDK 时
不集成 Facebook SDK,仅集成 IGAWorks SDK 时,参考如下内容。
- iOS
@interface AppDelegate () <IgaworksCoreDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[IgaworksCore shared].delegate = self;
return YES;
}
#pragma mark - IgaworksCoreDelegate
//open url with deep link
- (void)didReceiveDeeplink:(NSString *)deepLink
{
if (deepLink.length > 0) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:deepLink]];
}
}
- Unity iOS
public class IgaworksSample : MonoBehaviour
{
void Start ()
{
IgaworksCorePluginIOS.SetIgaworksCoreDelegate();
}
void Awake()
{
// add handle deep link event
IgaworksCorePluginIOS.didReceiveDeeplink += HandleDidReceiveDeeplink;
}
void OnDisable()
{
IgaworksCorePluginIOS.didReceiveDeeplink -= HandleDidReceiveDeeplink;
}
// handle deep link event
public void HandleDidReceiveDeeplink(string deepLink)
{
Debug.Log ("IgaworksSample : HandleDidReceiveDeeplink " + deepLink);
// url open
}
}
#情况 2. 集成 FaceBook SDK 时
根据 Facebook SDK 里 FetchDeferredAppLinkData API 的使用与否,提供 2种指南。选择对应的内容进行集成。
* 为了集成以下功能,必须集成 Core2.2.2 版本以上。[转移至下载页面]情况 2-1. 使用 FaceBook SDK 的 FetchDeferredAppLinkData API 时
使用 Facebook SDK 的 FetchDeferredAppLinkData API 时,参考如下内容进行集成。
- iOS ( setReferralUrl API )
@interface AppDelegate () <IgaworksCoreDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[IgaworksCore shared].delegate = self;
if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) {
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) {
if (error) {
NSLog(@"Received error while fetching deferred app link %@", error);
}
if (url) {
NSLog(@"Facebook SDK: Received fetching deferred app link %@", url);
[IgaworksCore setReferralUrl:url];
// open the app with deeplink url
[[UIApplication sharedApplication] openURL:url];
}
}];
}
return YES;
}
#pragma mark - IgaworksCoreDelegate
//open url with deep link
- (void)didReceiveDeeplink:(NSString *)deepLink
{
NSLog(@"Received deeplink url %@", deepLink);
}
- Unity iOS ( SetReferralUrl API )
FB.Mobile.FetchDeferredAppLinkData(DeepLinkCallback);
void DeepLinkCallback(IAppLinkResult result)
{
if (!String.IsNullOrEmpty(result.Url))
{
IgaworksCorePluginIOS.SetReferralUrl(result.Url);
}
}
情况 2-2. 不使用 FaceBook SDK 的 FetchDeferredAppLinkData API 时
不使用 Facebook SDK 的 FetchDeferredAppLinkData API 时,相同于不集成 Facebook SDK。因此若输入该条件,请参考 "#情况1" 的相关文档。