diff --git a/BitlySDK.framework.zip b/BitlySDK.framework.zip index 8f9c7b3..1aee326 100644 Binary files a/BitlySDK.framework.zip and b/BitlySDK.framework.zip differ diff --git a/README.md b/README.md index 2a5211b..ee6024f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Bitly iOS SDK -![Supported Platforms](https://img.shields.io/cocoapods/p/BitlySDK.svg) ![Releases](https://img.shields.io/github/release/bitly/bitly_ios_sdk_release.svg) [![Latest pod release](https://img.shields.io/cocoapods/v/BitlySDK.svg)](http://cocoapods.org/pods/BitlySDK) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.com/bitly/bitly_ios_sdk.svg?token=GQk2M5gzMUKUJCESKF18&branch=master)](https://travis-ci.com/bitly/bitly_ios_sdk) +![Supported Platforms](https://img.shields.io/cocoapods/p/BitlySDK.svg) ![Releases](https://img.shields.io/github/release/bitly/bitly_ios_sdk_release.svg) [![Latest pod release](https://img.shields.io/cocoapods/v/BitlySDK.svg)](http://cocoapods.org/pods/BitlySDK) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.com/bitly/bitly_ios_sdk.svg?token=GQk2M5gzMUKUJCESKF18&branch=master)](https://travis-ci.com/bitly/bitly_ios_sdk) [![Coverage Status](https://coveralls.io/repos/github/bitly/bitly_ios_sdk/badge.svg?t=xurvl2)](https://coveralls.io/github/bitly/bitly_ios_sdk) ## Getting Started If you do not have any mobile apps setup in your Bitly account you will need to refer to the user guide for setting up deep links in your account. @@ -41,14 +41,14 @@ The Apple app ID is your team ID and bundle ID joined with a period. In the App ``` 3. Drag the built `BitlySDK.framework` into your Xcode project -## Configure the Universal links +## Configure the Universal Links 1. In Xcode open your project file 2. Go to the Capabilities tab 3. Ensure that Associated Domains is enabled and expand it 4. Click on the + button and add your domain as `applinks:yourdomain.com` 5. Ensure that the yourprojectname.entitlements file is added to the appropriate build target -## Configure the SDK +## Configure the SDK for Universal Links 1. Import the SDK in your AppDelegate **Swift** @@ -89,6 +89,7 @@ The Apple app ID is your team ID and bundle ID joined with a period. In the App ``` > By default the Bitly SDK utilizes the IDFV to identify the user. If you which to use the IDFA to track the user simply call the `initializeWithDeviceId` method when initializing the SDK. + > You can also provide the access token for shortening with the `initializeWithShortening` and `initializeWithDeviceIdAndShortening` methods. 3. Handle incoming links @@ -101,10 +102,6 @@ The Apple app ID is your team ID and bundle ID joined with a period. In the App func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { return Bitly.handleOpenUrl(url); } - - func applicationDidBecomeActive(application: UIApplication) { - Bitly.handleApplicationDidBecomeActive() - } ``` **Objective-C** @@ -116,10 +113,6 @@ The Apple app ID is your team ID and bundle ID joined with a period. In the App - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [Bitly handleOpenUrl:url]; } - - - (void)applicationDidBecomeActive:(UIApplication *)application { - [Bitly handleApplicationDidBecomeActive]; - } ``` 4. Retry on error @@ -135,3 +128,60 @@ The Apple app ID is your team ID and bundle ID joined with a period. In the App ``` >If there are any issues in handling a Universal Link the operation can be retried using the following line of code in your response handler from step 2 + +## Configure the SDK for Shortening + +1. Configure an OAUTH token for your app http://bitly.com/a/oauth_apps +2. Import the SDK in your AppDelegate + + **Swift** + ```swift + import BitlySDK + ``` + + **Objective-C** + ```objective-c + #import + ``` + +3. Initialize the SDK on application initialization + + **Swift** + ```swift + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + Bitly.initializeShortening("YOUR_APP_ACCESS_TOKEN") + return true + } + ``` + + **Objective-C** + ```objective-c + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [Bitly initializeShortening:@"YOUR_APP_ACCESS_TOKEN"]; + return YES; + } + ``` + + > You can combine this initialization with the App Link initialization + +5. You can shorten from anywhere in your application + + **Swift** + ```swift + Bitly.shorten("http://theurlyouwishtoshorten.com") { response, error in + // response provides a BitlyResponse object which contains the shortened Bitlink + // response includes a status code + // error provides any errors in retrieving information about the URL + // Your custom logic goes here... + } + ``` + + **Objective-C** + ```objective-c + [Bitly shorten:@"http://theurlyouwishtoshorten.com" handler:^(BitlyResponse * response, NSString * error) { + // response provides a BitlyResponse object which contains the shortened Bitlink + // response includes a status code + // error provides any errors in retrieving information about the URL + // Your custom logic goes here... + }]; + ```