Headless iOS/Mac SDK for saving stuff to Pocket.

Overview

This SDK is deprecated

Howdy all! 👋 Thanks for checking out this repo. Your 👀 mean a lot to us. 💗

Unfortunately, this project is deprecated, and the code hosted here is woefully out of date. We wouldn't recommend it as anything other than a curiosity.

If you're interested in developing against the Pocket API, please visit our Developer Documentation.

Welcome!

Thanks for checking out the Pocket SDK. With a few lines of code, your app can quickly add support for saving URLs to users' Pocket lists.

Installing the Pocket SDK

The Pocket SDK is the fastest way to add Pocket integration to any iOS or Mac application. Adding the Pocket SDK to your app is incredibly easy. Follow the steps below and you can be saving urls to Pocket from your app within 15 minutes.

Step 1: Download the Pocket SDK

You can download the SDK at: http://getpocket.com/api/v3/pocket-objc-sdk.zip

You can also watch/checkout the SDK from GitHub at: http://github.com/Pocket/Pocket-ObjC-SDK. If you use recommend adding the Pocket SDK as a git submodule of your project by running git submodule add git://github.com/Pocket/Pocket-ObjC-SDK.git <path> from the root directory of your repository, replacing the <path> with the path you'd like it installed to.

If you use CocoaPods, you can add the PocketAPI pod to your Podfile. Then run pod install, and the Pocket SDK will be available in your project. See the documentation on the CocoaPods website if you want to set up a new or existing project.

The project download includes the SDK and an example project.

Step 2: Add the Pocket SDK to your project

  • Open your existing project.
  • Drag the SDK folder from the example project into your Xcode project.
  • Make sure the “Copy items into destination group’s folder (if needed)” checkbox is checked.
  • Select your Xcode project in the Project Navigator, select your application target, select “Build Phases”, and add Security.framework to your “Link Binary With Libraries” phase.

The SDK includes all necessary source files and does not have any other dependencies.

###Step 3: Obtain a platform consumer key###

When you register your app with Pocket, it will provide you with a platform consumer key. This key identifies your app to Pocket’s API.

If you have not obtained a consumer key yet, you can register one at http://getpocket.com/api/signup

Step 4: Add the Pocket URL scheme

Once you have the consumer key for the platform you are supporting, the application must register a URL scheme to receive login callbacks. By default, this is "pocketapp" plus your application's ID (which you can find at the beginning of the consumer key before the hyphen). So if your consumer key is 42-abcdef, your app ID is 42, and your URL scheme will be "pocketapp42".

If there are already URL schemes in your app’s Info.plist, you can either add the new URL scheme, or use an existing scheme by calling [[PocketAPI sharedAPI] setURLScheme:@"YOUR-URL-SCHEME-HERE"]. To add a URL Scheme, create a block like the one below in your Info.plist, updating it with the app’s scheme:

▾ URL Types (Array)
	▾ Item 0 (Dictionary)
		  URL Identifier (String) com.getpocket.sdk
		▾ URL Schemes (Array) (1 item)
			Item 0	(String) [YOUR URL SCHEME, like "pocketapp42"]

Or you can copy and paste the following into the XML Source for the Info.plist:

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLName</key>
		<string>com.readitlater</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>pocketapp9553</string>
		</array>
	</dict>
</array>

Step 5: Configure your App Delegate

The final steps to set up the Pocket SDK requires adding a few lines of code to your main app delegate. This is the class where you include iOS required methods like applicationDidFinishLaunching.

Import the PocketAPI Header

At the top of your app delegate source file (and anywhere you call the PocketAPI object), you'll need to include the PocketAPI header. At the top of your class you'll probably see other imports already. Simply add this line:

#import "PocketAPI.h"

Set Your Platform Consumer Key

The Pocket SDK requires your consumer key in order to make any requests to the API. Call this method with your registered consumer key when launching your app:

[[PocketAPI sharedAPI] setConsumerKey:@"Your Consumer Key Here"];

Add a method for the Pocket url-scheme

The final step is to give the SDK an opportunity to handle incoming URLs. If you do not already implement this method on your app delegate, simply add the following method:

-(BOOL)application:(UIApplication *)application
           openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication
        annotation:(id)annotation{

    if([[PocketAPI sharedAPI] handleOpenURL:url]){
        return YES;
    }else{
        // if you handle your own custom url-schemes, do it here
        return NO;
    }

}

Step 6: Start Saving to Pocket!

At this point you’ve properly installed the SDK and can now start making requests and saving urls to Pocket. Here is a two line example:

NSURL *url = [NSURL URLWithString:@"http://google.com"];
[[PocketAPI sharedAPI] saveURL:url handler: ^(PocketAPI *API, NSURL *URL, NSError *error){
    if(error){
        // there was an issue connecting to Pocket
        // present some UI to notify if necessary

    }else{
        // the URL was saved successfully
    }
}];

The example above uses blocks which requires iOS 4.0 or greater. If you have a need to support iOS 3.0, you can use the delegate or operation based methods.

Managing Accounts / Handling User Logins

Following Pocket’s API best practices, you’ll want to provide a way for the user to manage what account they are logged into. This is most commonly handled by adding a setting in your app’s option screen that lets the user configure their Pocket account. When the user taps this, you can simply call one line of code which will handle the entire authorization process:

[[PocketAPI sharedAPI] loginWithHandler: ^(PocketAPI *API, NSError *error){
if (error != nil)
{
	// There was an error when authorizing the user. The most common error is that the user denied access to your application.
	// The error object will contain a human readable error message that you should display to the user
	// Ex: Show an UIAlertView with the message from error.localizedDescription
}
else
{
	// The user logged in successfully, your app can now make requests.
	// [API username] will return the logged-in user’s username and API.loggedIn will == YES
}
}];

It is also recommended to observe changes to the PocketAPI's username and loggedIn properties to determine when the logged-in user changes. If iOS terminates your application while it is in the background (e.g. due to memory constraints), any pending login attempts are automatically saved and restored at launch if needed. Therefore, your delegate/block responses may not get called. If you need to update UI when the logged in user changes, register for observers on PocketAPI at application launch.

Calling Other Pocket APIs

To call other arbitrary APIs, pass the API's method name, the HTTP method name, and an NSDictionary of arguments. An NSDictionary with the response from the API will be passed to the handler.

NSString *apiMethod = ...;
 PocketAPIHTTPmethod httpMethod = ...; // usually PocketAPIHTTPMethodPOST
 NSDictionary *arguments = ...;

 [[PocketAPI sharedAPI] callAPIMethod:apiMethod
                       withHTTPMethod:httpMethod
                            arguments:arguments
                              handler: ^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error){
    // handle the response here
 }];

Enabling Extension Support

The first step is to "Enable Keychain Sharing" in both your app and extension capabilities in Xcode.

See Configuring Keychain Sharing for more information.

Final step is to add the following before you initialize the PocketAPI in your main app and extension:

[[PocketAPI sharedAPI] enableKeychainSharingWithKeychainAccessGroup:@"Your Keychain Access Group"];
[[PocketAPI sharedAPI] setConsumerKey:@"Your Consumer Key Here"];

After enabling keychain sharing, the app and extensions can access data that is securely stored in the keychain. From now on you can use the default methods of the PocketAPI class to save links from within extensions. See Step 6: Start Saving to Pocket! for more details.

Acknowledgements

The Pocket SDK uses the following open source software:

License

Copyright (c) 2015 Read It Later, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Login without Safari for iOS

    Login without Safari for iOS

    I rejected my iPhone app using Pocket API by Apple, because of following reason today. ** We found the following issues with the user interface of your app: The app opens a web page in mobile Safari for logging in, then returns the user to the app. The user should be able log in without opening Safari first. ** So I had made login api not to use safari. I hope you like this.

    opened by shuitic 12
  • iOS App using Pocket-ObjC-SDK is rejected because of OAuth login with Safari.

    iOS App using Pocket-ObjC-SDK is rejected because of OAuth login with Safari.

    My application which use Pocket API is rejected because of logging in with Safari. ** Reasons

    10.6: Apple and our customers place a high value on simple, refined, creative, well thought through interfaces. They take more work but are worth it. Apple sets a high bar. If your user interface is complex or less than very good it may be rejected 10.6

    We found the following issues with the user interface of your app: The app opens a web page in mobile Safari for logging in, then returns the user to the app. The user should be able log in without opening Safari first. **

    I explained like this. ** This application's target user has already had "Pocket" app which is free app. If they have "Pocket", they can login without Safari. Is this enough for this? **

    But they answered like this. ** Thank you for your response regarding your app. However, we will still require login within the app. ** What a silly reason this is.

    I made pull request today. If you have a same problem, fork my solution.

    opened by shuitic 7
  • Remove SFHFKeychainUtils

    Remove SFHFKeychainUtils

    Hi Steve,

    Could you please make SFHFKeychainUtils a dependency in cocoapods file and remove it from the SDK folder? As of right now, it results in Xcode warning "Multiple build commands for output file" when some other pods have SFHFKeychainUtils as their dependency.

    opened by romaonthego 5
  • Getting saved values in PocketAPIKeychainUtils

    Getting saved values in PocketAPIKeychainUtils

    @maicki: In the feature/extension-support branch, it appears that the following change (to include accessGroup) is warranted in #storeUsername:andPassword:forServiceName:inAccessGroup:updateExisting:error:

    --- a/SDK/PocketAPIKeychainUtils.m
    +++ b/SDK/PocketAPIKeychainUtils.m
    @@ -162,7 +162,7 @@ static NSString *PocketAPIKeychainUtilsErrorDomain = @"PocketAPIKeychainUtilsErr
    
     	// See if we already have a password entered for these credentials.
     	NSError *getError = nil;
    -	NSString *existingPassword = [PocketAPIKeychainUtils getPasswordForUsername: username andServiceName: serviceName error:&getError];
    +	NSString *existingPassword = [PocketAPIKeychainUtils getPasswordForUsername: username andServiceName: serviceName inAccessGroup:accessGroup error:&getError];
    
     	if ([getError code] == -1999) {
     		// There is an existing entry without a password properly stored (possibly as a result of the previous incorrect version of this code.
    
    opened by mackinra 4
  • loginWithHandler never calls callback

    loginWithHandler never calls callback

    'm trying to login with pocket:

    [[PocketAPI sharedAPI] loginWithHandler: ^(PocketAPI *API, NSError *error){
        NSLog(@"FINISHED")
    }];
    

    After this call, I'm being redirected to Pocket app, after I click "Authorize" button, I'm being redirected back to my app. But NSLog(@"FINISHED"); had never been called.

    Also in my AppDelegate.m I have this method:

    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
      if([[PocketAPI sharedAPI] handleOpenURL:url]){
        NSLog(@"YES, %@", url);
        return YES;
      }else{
        // if you handle your own URLs, do it here
        return NO;
      }
    }
    

    It gets called after I click on "Authorize" button, and I see YES, pocketapp*****:authorizationFinished in the console.

    Why loginWithHandler callback never gets called?

    opened by liubko 4
  • access to acces_token

    access to acces_token

    is there any way that we can use the iOS SDK for authentification and then get the access token whihc would allow us to fetch articles server side? would this be frowned upon as a way of doing things?

    I know it works the other way around, the node.js lib for instance gives us the login url that we can use on the client side and then we can do the rest on the server side.

    cheers

    opened by tzapu 2
  • Fix -Wundef warnings

    Fix -Wundef warnings

    Vanilla iOS projects define DEBUG to be 1 in the Debug build configuration, and don't define DEBUG at all in the Release build configuration. That means that if you make a release build DEBUG is implicitly 0, but if you turn on the -Wundef warning flag you'll get warnings about this implicit value.

    screen shot 2015-02-24 at 11 26 56 am

    This pull request explicitly makes sure both that DEBUG is defined and that its value evaluates to true. It also fixes another warning related to using an iOS-only macro in the Mac project.

    This mirrors a change I made to our FLAnimatedImage project at https://github.com/Flipboard/FLAnimatedImage/pull/66.

    opened by timonus 2
  • "loginWithHandler" cannot call back in iOS7

    I'm using this SDK on Xcode 5.1 for developing an APP(using ARC).

    And I use this method to authorize. When the program call this method it can redirect to the authorize web page and after click the "Authorize" button it can go back to the app. However, nothing happens after that. I am not login and and code in the block never be call.

    I also want to catch "PocketAPILoginFinishedNotification" by using NSNotificationCenter but don't success.

    opened by wuzhou 2
  • fixed crash on saving (iOS4)

    fixed crash on saving (iOS4)

    When NSJSONSerialization is not available (iOS4), HTTP body will be assembled by pkt_URLEncodedFormString:. The argument (NSDictionary) may be contain NSNumber, but this method does not transfer the type of it. This leads to crash in [PocketAPIOperation encodeForURL:value].

    I avoided this issue by transferring the type.

    example of argument

    key(NSString): time
    value(NSNumber): 1361867614
    
    key(NSString): consumer_key
    value(NSString): *****
    
    key(NSString): url
    value(NSString): http://www.example.com
    
    key(NSString): access_token
    value(NSString): *****
    
    opened by ishkawa 2
  • Fix warnings in Xcode 9

    Fix warnings in Xcode 9

    These were pointers to consts which can be modified at runtime by changing the pointer. I've modified them to be consts to pointers which are static once compiled.

    This warning would appear when attempting to use the const in: [NSNotificationCenter addObserver:selector:name:object:]

    These warnings do not appear in the test app because the test app explicitly casts these consts to (NSString *) at the callsite.

    For more information see here: https://stackoverflow.com/questions/6828831/sending-const-nsstring-to-parameter-of-type-nsstring-discards-qualifier

    opened by djds23 1
  • Change public header to Pocket.h

    Change public header to Pocket.h

    PocketAPI cannot be built with Cocoapods when use "use_frameworks!"

    Cocoapods generates PocketAPI-umbrella.h automatically.

    #import <UIKit/UIKit.h>
    
    #import "PocketAPI+NSOperation.h"
    #import "PocketAPI.h"
    #import "PocketAPIKeychainUtils.h"
    #import "PocketAPILogin.h"
    #import "PocketAPIOperation.h"
    #import "PocketAPITypes.h"
    
    FOUNDATION_EXPORT double PocketAPIVersionNumber;
    FOUNDATION_EXPORT const unsigned char PocketAPIVersionString[];
    

    The problem is the order of #import. "PocketAPI+NSOperation.h" doesn't include PocketAPI.

    And we don't need to use PocketAPI+NSOperation.h in public. I removed unnecessary headers in podspec.

    opened by ryohey 1
  • Unable to authorize the user

    Unable to authorize the user

    Hi

    I have done pocket user authentication and I got code, redirectUI .

    Using that, I am trying authorize the following url https://getpocket.com/auth/authorize?request_token=(requestToken)&redirect_uri=(redirectUrl)

    Its showing "There was a problem with you app."Please find the attachment for the same.

    Can you please help me on this. Thanks Dhanunjaya screen shot 2017-04-21 at 11 20 31 pm

    opened by mdhanu11 3
  • Add import for build with framework

    Add import for build with framework

    Hi Pocket

    This pull-request fixes that PocketAPI cannot be built with Cocoapods when use "use_frameworks!"

    Podfile

    platform :ios, '8.0'
    use_frameworks!
    
    target 'pockettest' do
      pod 'PocketAPI'
    end
    

    AppDelegate.swift

    import PocketAPI
    

    And I got error.

    2016-01-18 14 10 06

    The problem is the order of #import in PocketAPI-umbrella.h. Cocoapods generates PocketAPI-umbrella.h automatically.

    #import <UIKit/UIKit.h>
    
    #import "PocketAPI+NSOperation.h"
    #import "PocketAPI.h"
    #import "PocketAPIKeychainUtils.h"
    #import "PocketAPILogin.h"
    #import "PocketAPIOperation.h"
    #import "PocketAPITypes.h"
    
    FOUNDATION_EXPORT double PocketAPIVersionNumber;
    FOUNDATION_EXPORT const unsigned char PocketAPIVersionString[];
    

    "PocketAPI+NSOperation.h" doesn't include PocketAPI. I don't know this is the right way to integrate with Cocoapods but this fixes the problem. Thanks.

    opened by ryohey 0
  • Broken when bridging over to use with Swift

    Broken when bridging over to use with Swift

    I've tried it on both on iOS and OSX, and the error is occurring at the same place. When instantiating UIApplication on iOS or NSWorkspace on iOS, it throws the following error:

    Semantic Issue: Use of undeclared identifier 'UIApplication' (for iOS, on OSX it's 'NSWorkspace' in the error).

    I have an open stackoverflow question trying to get to the root of it as well, but any help from your side would be very much appreciated.

    The bridging is working fine, but I had to add the '-fno-objc-arc' to all the pocket api files, so it doesn't freak out over ARC.

    Update: got it working on iOS by adding the following in PocketAPI.m and PocketAPILogin.m right below the imports.

    #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
    #import <UIKit/UIKit.h>
    #endif
    

    Update 2:

    Got it working on OSX and iOS by adding the following after the imports in PocketAPILogin.m and PocketAPI.m:

    #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
    #import <UIKit/UIKit.h>
    #endif
    
    #ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
    #import <Appkit/AppKit.h>
    #endif
    

    Can do a fork/pull request for it if you want.

    opened by individual11 4
  • Added UIActivity subclass

    Added UIActivity subclass

    PocketAPIActivity is a UIActivity subclass that can be used with UIActivityViewController to save NSURLs to Pocket. To use it, simply add [[PocketAPIActivity alloc] init] to the array of activities when you create a UIActivityViewController:

    [[UIActivityViewController alloc] initWithActivityItems:@[ [NSURL URLWithString:@"http://google.com"] ] applicationActivities:@[ [[PocketAPIActivity alloc] init] ]];
    

    The activity will add all NSURL activity items to pocket, returning a failure if any of them return an error.

    The activity will show up in the view controller only if:

    1. There is at least 1 NSURL in the activity items
    2. The Pocket iOS app is installed or the user has logged in

    This behavior means that you can add the activity to all your UIActivityViewControllers and it will only appear when relevant.

    opened by davbeck 2
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter 45 Nov 29, 2022
Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

Radar COVID 146 Nov 24, 2022
TelegramStickersImport — Telegram stickers importing SDK for iOS

TelegramStickersImport — Telegram stickers importing SDK for iOS TelegramStickersImport helps your users import third-party programaticaly created sti

null 35 Oct 26, 2022
Muxer used on top of Feed iOS SDK for airplay

FeedAirplayMuxer Muxer used on top of Feed iOS SDK for airplay purposes. Demo Project --> https://github.com/feedfm/AirplayDemo Feed Airplay Muxer is

Feed Media 0 May 6, 2022
Basispay IOS SDK Version 2

BasisPay-IOS-KIT BasisPay IOS Payment Gateway kit for developers INTRODUCTION This document describes the steps for integrating Basispay online paymen

null 0 Oct 21, 2021
Release repo for Gini Bank SDK for iOS

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Gini GmbH 1 Dec 6, 2022
Da Xue Zhang Platform Lvb iOS SDK

Cloud_Lvb_SDK iOS API Reference Dxz Meeting iOS SDK是为 iOS 平台用户音视频服务的开源 SDK。通过大学长开放平台自研RTC,RTM系统,为客户提供质量可靠的音视频服务。 类 类名 描述 CLS_PlatformManager SDK的音视频主要

null 8 Jan 10, 2022
PayPal iOS SDK

PayPal iOS SDK Welcome to PayPal's iOS SDK. This library will help you accept card, PayPal, Venmo, and alternative payment methods in your iOS app. Su

PayPal 25 Dec 14, 2022
Unofficial Notion API SDK for iOS & macOS

NotionSwift Unofficial Notion SDK for iOS & macOS. This is still work in progress version, the module interface might change. API Documentation This l

Wojciech Chojnacki 59 Jan 8, 2023
150,000+ stickers API & SDK for iOS Apps.

English | 한국어 Stipop UI SDK for iOS Stipop SDK provides over 150,000 .png and .gif stickers that can be easily integrated into mobile app chats, comme

Stipop, Inc. 19 Dec 20, 2022
Spotify SDK for iOS

Spotify iOS SDK Overview The Spotify iOS framework allows your application to interact with the Spotify app running in the background on a user's devi

Spotify 522 Jan 6, 2023
Evernote Cloud SDK for iOS

Evernote Cloud SDK 3.0 for iOS This is the official Evernote SDK for iOS. To get started, follow the instructions bellow. Additional information can b

Evernote 256 Oct 6, 2022
iOS SDK for the Box Content API

Box iOS SDK Getting Started Docs: https://developer.box.com/guides/mobile/ios/quick-start/ NOTE: The Box iOS SDK in Objective-C (prior to v3.0.0) has

Box 112 Dec 19, 2022
OneDrive SDK for iOS

Get started with the OneDrive SDK for iOS Integrate the OneDrive API into your iOS app! 1. Installation Install via Cocoapods Install Cocoapods - Foll

OneDrive 101 Dec 19, 2022
Stripe iOS SDK

Stripe iOS SDK The Stripe iOS SDK makes it quick and easy to build an excellent payment experience in your iOS app. We provide powerful and customizab

Stripe 1.8k Jan 5, 2023
AWS SDK for iOS. For more information, see our web site:

AWS SDK for iOS The AWS SDK for iOS provides a library and documentation for developers to build connected mobile applications using AWS. Features / A

AWS Amplify 1.6k Dec 26, 2022
Zendesk Mobile SDK for iOS

⚠️ This Repository has been deprecated, please go to here for the Zendesk Support SDK ⚠️ Zendesk Mobile SDK for iOS Zendesk SDK for mobile is a quick,

Zendesk 113 Dec 24, 2022
PlayKit: Kaltura Player SDK for iOS

Kaltura Player SDK Demo: Demo repo. If you are a Kaltura customer, please contact your Kaltura Customer Success Manager to help facilitate use of this

Kaltura 77 Jan 3, 2023
Uber Rides iOS SDK (beta)

Uber Rides iOS SDK This Swift library allows you to integrate the Uber Rides API into your iOS app. Requirements iOS 8.0+ Xcode 10.0+ Swift 4.2+ Insta

Uber Open Source 343 Jan 4, 2023