Appgain SmartLinking sdk

appgain-smartdeeplink-sdk makes it easy to use Appgain’s smart deep linking generation service.

  1. Why use smart deep linking?
  2. Requirements
  3. Integration
  4. Usage

Why use smart deep linking?

Smart Deep Link is a link with a certain form of intelligence that brings users from different paths right to your app or other apps depending on the where the link is opened from.

Requirements

  • iOS 8.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+
  • Xcode 7.3

Integration

CocoaPods (iOS 8+, OS X 10.9+)

You can use CocoaPods to install SmartLinkingby adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
pod 'SmartLinking'
end

Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 8.0:

Manually (iOS 8+, OS X 10.9+)

To use this library in your project manually you may:

  1. for Projects, just drag SmartLinking.framework to the project tree
  2. for Workspaces, include the whole SmartLinking.xcodeproj
  3. Be sure to add the framework to embed frameworks in build phases

Usage

Swift

swift
import SmartLinking
swift
let ios = Platform(primary: "twitter://post?message=rewrew", fallback: "tel:123")
let android = Platform(primary: "sms:123?body=hello", fallback: "twitter://search?query=appgain")

let targets = Targates(android: android, ios: ios, web: "http://appgain.io")
let launchPage = LaunchPage(header: "hello")

let body = LinkerPostBody(name: "test links", slug: "mylink", withLaungePage: launchPage, withTargets: targets, withDescription: "description", status: "active")

self.activityIndicator.hidden = false
activityIndicator.startAnimating()
SmartLinker.createSmartLinkForUserName("[Your User name ]", password: "[Your Pass]", appId: "[Your appgain.io APP ID]", postBody: body) { (result, error) in

var message: String = "No result. Try again."

if error != nil {
message = "Error:\(error!.localizedDescription)"
} else {
if result != nil {
if result!.status == "success" {
message = "smartlink = \(result!.smartlink!)"
} else {
message = "Failure message:\(result!.message!)"
}
} else {
message = "Data was empty. Please call the system admin"
}
}

dispatch_async(dispatch_get_main_queue(), {
self.resultsLabel.text = message
self.activityIndicator.stopAnimating()
self.activityIndicator.hidden = true
})
}

Objective-c

objectivec
Platform *ios = [[Platform alloc] initWithPrimary:@"twitter://post?message=hello" fallback:@"tel:123"];
Platform *android = [[Platform alloc] initWithPrimary:@"twitter://post?message=hello" fallback:@"tel:123"];
Targates *targets = [[Targates alloc] initWithAndroid:android ios:ios web:@"http://myweb.net"];
LaunchPage *luanchPage = [[LaunchPage alloc] initWithHeader:@"hello"];
LinkerPostBody *postBody = [[LinkerPostBody alloc] initWithName:@"test links" slug:@"mylink" withLaungePage:luanchPage withTargets:targets withDescription:@"description" status:@"active"];
self.activityIndicator.hidden = NO;
[SmartLinker createSmartLinkForUserName:@"[Your User name ]" password:@"[Your Pass]" appId:@"[Your Appgain.io APP ID]" postBody:postBody completionHandler:^(LinkerResult *linkerResult, NSError *error) {

NSString *message = @"No result. Try again.";

if (error) {
message = [NSString stringWithFormat:@"Error:%@", error.localizedDescription];
} else {
if (linkerResult) {
if ([linkerResult.status isEqualToString:@"success"]) {
message = [NSString stringWithFormat:@"smartlink = %@", linkerResult.smartlink];
} else {
message = [NSString stringWithFormat:@"Failure message:%@", linkerResult.message];
}
} else {
message = @"Data was empty. Please call the system admin";
}
}
dispatch_async(dispatch_get_main_queue(), ^{
self.resultsLabel.text = message;
[self.activityIndicator stopAnimating];
self.activityIndicator.hidden = YES;
});
}];
Categories: How To Guides

Leave a Reply

Your email address will not be published. Required fields are marked *