URXSearch 0.5.4

URXSearch 0.5.4

测试已测试
语言语言 Obj-CObjective C
许可证 Apache 2
发布上次发布2015年8月

Robert S. JonesJames Lawrence Turner 维护。



URXSearch 0.5.4

  • URX

URX iOS SDK

URX iOS SDK 是 URX 深度链接搜索 API 的包装器。

要获取您的 API 密钥,请访问 dashboard.urx.com

您可以使用 CocoaPods 或作为静态 Framework 安装 urx-sdk-ios,由您决定。

步骤 1:将 URXSearch 添加到您的 Podfile

pod 'URXSearch' 设置

步骤 2:安装 URXSearch CocoaPod

$ pod install

步骤 3:升级

您始终可以访问 URXSearch 查看最新版本。

检查更新

$ pod search URXSearch

更新到最新版本

$ pod update

使用 Framework 设置

步骤 1:将 URXSearch Framework 添加到您的项目

首先,克隆此仓库。然后,将 URXSearch.framework 拖放到您项目 "Frameworks" 目录中。

步骤 2:链接到 URXSearch 二进制和头文件

确保 URXSearch.framework 已添加到您项目的二进制文件中。在您项目设置中,选择您的 Target 并选择 Build Phases 标签。在 Link Binary With Libraries 阶段您应该看到 URXSearch.framework。如果没有,请按 + 按钮,并从选项列表中选择它。

步骤 3:设置 API 密钥

为了使用 URX 的 SDK,您需要提供您的 API 密钥。如果您还没有,请今天访问 URX.com 注册。

要将您的API密钥添加到项目中,在Info.plist文件中添加一行,键为“URX API Key”,值为您的API密钥。

步骤4:设置-ObjC链接器标志

在项目的构建设置中,确保在“其他链接器标志”设置中添加-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);
}];
使用应用商店回退解析URL
#import <URXSearch/URX.h>

...

[[URXResolutionRequest requestFromUrl:@"http://www.spotify.com"] resolveAsynchronouslyWithAppStoreFallbackAndFailureHandler:^(URXAPIError *error) {
    // RESOLUTION FAILURE HANDLER
    NSLog(@"%@", error.errorMessage);
}];
使用网络回退解析URL
#import <URXSearch/URX.h>

...

[[URXResolutionRequest requestFromUrl:@"http://www.spotify.com"] resolveAsynchronouslyWithWebFallbackAndFailureHandler:^(URXAPIError *error) {
    // RESOLUTION FAILURE HANDLER
    NSLog(@"%@", error.errorMessage);
}];
使用延迟深链接解析URL

注意 您应确保在任何给定时间内只有一个`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!"];
延迟深链接通知

延迟深度链接发布了一系列通知,以便您根据安装进度采取适当的操作。

URXResolutionResponseWillStart

在应用开始安装时发布。

URXResolutionResponseDidFinish

在应用安装完成后发布。如果发生错误,userInfo字典将包含一个带有URXResolutionResponseErrorKey键的NSError对象,该对象描述了错误。

URXResolutionResponseWillLoadProductDetails

在尝试从应用商店加载产品详情之前发布。

URXResolutionResponseDidLoadProductDetails

尝试从应用商店加载产品详情完成后发布。在userInfo字典中包括一个指示是否已加载应用详情的URXResolutionResponseLoadAppDetailsSuccessKey。如果没有,延迟深度链接将失败,并将错误作为URXResolutionResponseDidFinish通知的一部分报告。

URXResolutionResponseWillPresentStore

在呈现SKStoreProductViewController之前发布。

URXResolutionResponseDidPresentStore

在呈现SKStoreProductViewController后发布。

URXResolutionResponseWillDismissStore

在即将关闭SKStoreProductViewController之前发布。

URXResolutionResponseDidDismissStore

在关闭SKStoreProductViewController后发布。

URXResolutionResponseWillLaunchDeepLink

在尝试启动延迟深度链接之前发布。注意从发布此通知到实际应用切换之间可能会有显著的延迟(几秒钟)。因此,您不应依赖于此通知来更新您的UI。您应与此通知结合使用UIApplicationDidEnterBackgroundNotification

许可证

版权所有 2015 URX

许可协议为Apache License,版本2.0(以下简称“许可证”);除非您明确遵守此许可证的规定,否则不得使用此文件。您可以从以下网站获得许可证的副本:

https://apache.ac.cn/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则在许可证下分发的软件按“原样”分发,没有任何形式的保证或条件,无论是明示的还是暗示的。有关许可证的具体语言,请参阅许可证。