CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Aug 2015 |
Maintained by Robert S. Jones, James Lawrence Turner.
The URX iOS SDK is a wrapper for URX's Deep Link Search API.
To receive your API key, please visit dashboard.urx.com.
You can install urx-sdk-ios
with CocoaPods, or as a static Framework. It's up to you.
URXSearch
to your Podfile
:pod 'URXSearch'
set
URXSearch
CocoaPod:$ pod install
You can always visit URXSearch to see the latest version.
$ pod search URXSearch
$ pod update
First, clone this repository. Then, drag and drop the URXSearch.framework
into the "Frameworks" directory of your project.
Make sure that the URXSearch.framework
has been added to your project's binary. In your project settings, select your Target
and select the Build Phases
tab. In the Link Binary With Libraries
phase you should see URXSearch.framework
. If not, hit the + button and select it from the list of options.
In order to use URX's SDKs, you need to provide your API key. If you don't already have one, visit URX.com to sign up today.
To add your API Key to your project, add a String
row to your Info.plist file with URX API Key
as the key and your API key as the value.
In your project's Build Settings, make sure to add -ObjC in the "Other Linker Flags" setting.
#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);
}];
For more advanced boolean operations and complex queries, see the API Search Operators documentation.
#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);
}];
NOTE You should take care to make sure only one of instance of resolveAsynchronouslyWithStoreKitFallbackAndFailureHandler:
is active at a given time. You can ensure this by observing the URXResolutionResponseDidFinish
notification, which is posted just before the operation completes.
#import <URXSearch/URX.h>
...
[[URXResolutionRequest requestFromUrl:@"http://www.spotify.com"] resolveAsynchronouslyWithStoreKitFallbackAndFailureHandler:^(URXAPIError *error) {
// RESOLUTION FAILURE HANDLER
NSLog(@"%@", error.errorMessage);
}];
You can cancel an deferred deeplink at any time. Note that cancelling the Deferred Deeplink will only cancel the deeplink--not a running app install.
[URXResolutionResponse cancelDeferredDeeplink];
There are a number of ways you can configure URXResolutionRequest's Deferred Deeplink functionality:
NOTE If you disable the automatic loading views, you should be sure to observe the various URXResolutionResponse
notifications and update your UI accordingly.
[URXSearch setShouldPresentLoadingViews:NO];
This is a UIAlert that gets presented if the user navigates away from the SKStoreProductViewController
before the app installation finishes.
// 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!"];
Deferred Deeplinks posts a number of notifications to allow you to take appropriate action based on the install progress.
Posted when the app install starts.
Posted when the app install finishes. If an error occurred, the userInfo
dictionary will contain a URXResolutionResponseErrorKey
key with an NSError
object describing the error.
Posted before attempting to load product details from the app store.
Posted after the attempt to load product details from the app store completes. The userInfo
dictionay will contain a URXResolutionResponseLoadAppDetailsSuccessKey
which indicates whether or not the app details were loaded. If not, the deferred deeplink will fail and the error will be reported as part of the URXResolutionResponseDidFinish
notification.
Posted just before presenting the SKStoreProductViewController
.
Posted after presenting the SKStoreProductViewController
.
Posted just before dismissing the SKStoreProductViewController
.
Posted after dismissing the SKStoreProductViewController
.
Posted just before attempting to launch the Deferred Deeplink.
NOTE It's possible for there to be a sizeable delay (several seconds) between when this notification is posted and when the app switch actually happens. For this reason, you should not depend on this notification for updating your UI. You should use this notification in conjuction with UIApplicationDidEnterBackgroundNotification
.
Copyright 2015 URX
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.