测试已测试 | ✓ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布上次发布 | 2015年8月 |
由 Robert S. Jones,James Lawrence Turner 维护。
URX iOS SDK 是 URX 深度链接搜索 API 的包装器。
要获取您的 API 密钥,请访问 dashboard.urx.com。
您可以使用 CocoaPods 或作为静态 Framework 安装 urx-sdk-ios
,由您决定。
URXSearch
添加到您的 Podfile
pod 'URXSearch'
设置
URXSearch
CocoaPod$ pod install
您始终可以访问 URXSearch 查看最新版本。
$ pod search URXSearch
$ pod update
首先,克隆此仓库。然后,将 URXSearch.framework
拖放到您项目 "Frameworks" 目录中。
确保 URXSearch.framework
已添加到您项目的二进制文件中。在您项目设置中,选择您的 Target
并选择 Build Phases
标签。在 Link Binary With Libraries
阶段您应该看到 URXSearch.framework
。如果没有,请按 + 按钮,并从选项列表中选择它。
为了使用 URX 的 SDK,您需要提供您的 API 密钥。如果您还没有,请今天访问 URX.com 注册。
要将您的API密钥添加到项目中,在Info.plist文件中添加一行
在项目的构建设置中,确保在“其他链接器标志”设置中添加-ObjC。
#import <URXSearch/URX.h>
...
[[URXTerm termWithKeywords:@"ellie goulding"] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
URXSearchResult *result = response.results[0];
// The Search Result Content's Title
NSLog(@"%@", result.name);
// The Search Result Content's image url
NSLog(@"%@", result.imageUrl);
// The Search Result Content's longer text description
NSLog(@"%@", result.descriptionText);
// The Search Result Content's call to action text (ie. "Buy Tickets")
NSLog(@"%@", result.callToActionText);
// The Search Result Content's app name
NSLog(@"%@", result.appName);
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
#import <URXSearch/URX.h>
...
[[URXTerm termWithKeywords:@"ellie goulding"] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
// Note: Integrations usually display the search result for the user
// and set click handler to trigger resolving user to destination.
// Resolve to the deeplink only if the app is installed,
// otherwise fallback to the app store.
[response.results[0] resolveAsynchronouslyWithAppStoreFallbackAndFailureHandler:^(URXAPIError *error) {
NSLog(@"%@", error.errorMessage);
}];
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
#import <URXSearch/URX.h>
...
[[URXTerm termWithKeywords:@"ellie goulding"] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
}];
#import <URXSearch/URX.h>
...
[[URXPhrase phraseWithString:@"ellie goulding"] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
}];
#import <URXSearch/URX.h>
...
[[[URXTerm termWithKeywords:@"ellie goulding"] and:[URXActionFilter listenAction]] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
#import <URXSearch/URX.h>
...
[[[URXTerm termWithKeywords:@"ellie goulding"] and:[URXDomainFilter domainWithPLD:@"spotify.com"]] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
#import <URXSearch/URX.h>
...
[[[URXTerm termWithKeywords:@"ellie goulding"] and:[URXNearFilter nearLatitude:37.7811919 AndLongitude:-122.3950664]] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
有关更高级的布尔运算和复杂查询,请参阅API搜索操作符文档。
#import <URXSearch/URX.h>
...
[[URXRawQuery queryFromString:@"ellie goulding action:BuyAction near:\"San Francisco\""] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
}];
#import <URXSearch/URX.h>
...
[[URXTerm termWithKeywords:@"ellie goulding"] searchAsynchronouslyWithSuccessHandler:^(URXSearchResponse *response) {
// SEARCH SUCCESS HANDLER
// Note: Integrations usually display the search result for the user
// and set click handler to trigger resolving user to destination.
// Resolve to the deeplink only if the app is installed,
// otherwise fallback to the web page.
[response.results[0] resolveAsynchronouslyWithWebFallbackAndFailureHandler:^(URXAPIError *error) {
NSLog(@"%@", error.errorMessage);
}];
} andFailureHandler:^(URXAPIError *error) {
// SEARCH FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
#import <URXSearch/URX.h>
...
[[URXResolutionRequest requestFromUrl:@"http://www.spotify.com"] resolveAsynchronouslyWithAppStoreFallbackAndFailureHandler:^(URXAPIError *error) {
// RESOLUTION FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
#import <URXSearch/URX.h>
...
[[URXResolutionRequest requestFromUrl:@"http://www.spotify.com"] resolveAsynchronouslyWithWebFallbackAndFailureHandler:^(URXAPIError *error) {
// RESOLUTION FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
注意 您应确保在任何给定时间内只有一个`resolveAsynchronouslyWithStoreKitFallbackAndFailureHandler:`实例处于活动状态。可以通过观察操作完成前发布的`URXResolutionResponseDidFinish`通知来确保这一点。
#import <URXSearch/URX.h>
...
[[URXResolutionRequest requestFromUrl:@"http://www.spotify.com"] resolveAsynchronouslyWithStoreKitFallbackAndFailureHandler:^(URXAPIError *error) {
// RESOLUTION FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
您可以在任何时候取消延迟的深链接。请注意,取消延迟深链接只会取消深链接,而不会取消正在运行的应用安装。
[URXResolutionResponse cancelDeferredDeeplink];
您可以通过多种方式配置URXResolutionRequest的延迟深链接功能
注意 如果您禁用了自动加载视图,则务必观察各种`URXResolutionResponse`通知并相应地更新您的UI。
[URXSearch setShouldPresentLoadingViews:NO];
这是如果用户在应用安装完成之前离开`SKStoreProductViewController`,将呈现的UIAlertView。
// Customize the UIAlert Title
[URXSearch setDeeplinkAlertTitle:@"A Title"];
// Customize the UIAlert message
[URXSearch setDeeplinkAlertMessage:@"A Message"];
// Customize the UIAlert cancel button title
[URXSearch setDeeplinkAlertCancelButtonTitle:@"No Way!"];
// Customize the UIAlert confirm button title
[URXSearch setDeeplinkAlertConfirmButtonTitle:@"Take Me There!"];
延迟深度链接发布了一系列通知,以便您根据安装进度采取适当的操作。
在应用开始安装时发布。
在应用安装完成后发布。如果发生错误,userInfo
字典将包含一个带有URXResolutionResponseErrorKey
键的NSError
对象,该对象描述了错误。
在尝试从应用商店加载产品详情之前发布。
尝试从应用商店加载产品详情完成后发布。在userInfo
字典中包括一个指示是否已加载应用详情的URXResolutionResponseLoadAppDetailsSuccessKey
。如果没有,延迟深度链接将失败,并将错误作为URXResolutionResponseDidFinish
通知的一部分报告。
在呈现SKStoreProductViewController
之前发布。
在呈现SKStoreProductViewController
后发布。
在即将关闭SKStoreProductViewController
之前发布。
在关闭SKStoreProductViewController
后发布。
在尝试启动延迟深度链接之前发布。注意从发布此通知到实际应用切换之间可能会有显著的延迟(几秒钟)。因此,您不应依赖于此通知来更新您的UI。您应与此通知结合使用UIApplicationDidEnterBackgroundNotification
。
版权所有 2015 URX
许可协议为Apache License,版本2.0(以下简称“许可证”);除非您明确遵守此许可证的规定,否则不得使用此文件。您可以从以下网站获得许可证的副本:
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则在许可证下分发的软件按“原样”分发,没有任何形式的保证或条件,无论是明示的还是暗示的。有关许可证的具体语言,请参阅许可证。