{"id":1866,"url":"https://github.com/Pocket/Pocket-ObjC-SDK","last_synced_at":"2025-08-02T05:32:52.236Z","repository":{"id":3435234,"uuid":"4487474","full_name":"Pocket/Pocket-ObjC-SDK","owner":"Pocket","description":"Headless iOS/Mac SDK for saving stuff to Pocket.","archived":true,"fork":false,"pushed_at":"2021-03-08T19:28:42.000Z","size":530,"stargazers_count":229,"open_issues_count":5,"forks_count":75,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-07-01T02:51:07.901Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://getpocket.com/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pocket.png","metadata":{"files":{"readme":"README.html","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-29T20:58:06.000Z","updated_at":"2024-10-01T15:37:52.000Z","dependencies_parsed_at":"2022-09-07T08:21:03.956Z","dependency_job_id":null,"html_url":"https://github.com/Pocket/Pocket-ObjC-SDK","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/Pocket/Pocket-ObjC-SDK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pocket%2FPocket-ObjC-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pocket%2FPocket-ObjC-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pocket%2FPocket-ObjC-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pocket%2FPocket-ObjC-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pocket","download_url":"https://codeload.github.com/Pocket/Pocket-ObjC-SDK/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pocket%2FPocket-ObjC-SDK/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339403,"owners_count":24234544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:57.648Z","updated_at":"2025-08-02T05:32:51.931Z","avatar_url":"https://github.com/Pocket.png","language":"Objective-C","funding_links":[],"categories":["SDK","Official","官方的","Objective-C"],"sub_categories":["Official","Other free courses"],"readme":"\u003c?xml version=\"1.0\" encoding=\"UTF-8\" ?\u003e\n\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\u003e\n\u003chtml\u003e\n\t\u003chead\u003e\n\t\t\u003cmeta name=\"Format\" content=\"complete\" /\u003e\n\t\u003c/head\u003e\n\u003cbody\u003e\n\u003ch1 id=\"welcome\"\u003eWelcome!\u003c/h1\u003e\n\n\u003cp\u003eThanks for checking out the Pocket SDK. With a few lines of code, your app can quickly add support for saving URLs to users\u0026#8217; Pocket lists.\u003c/p\u003e\n\n\u003ch2 id=\"installingthepocketsdk\"\u003eInstalling the Pocket SDK\u003c/h2\u003e\n\n\u003cp\u003eThe 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.\u003c/p\u003e\n\n\u003ch3 id=\"step1:downloadthepocketsdk\"\u003eStep 1: Download the Pocket SDK\u003c/h3\u003e\n\n\u003cp\u003eYou can download the SDK at: \u003ca href=\"http://getpocket.com/api/v3/pocket-objc-sdk.zip\"\u003ehttp://getpocket.com/api/v3/pocket-objc-sdk.zip\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003eYou can also watch/checkout the SDK from GitHub at: \u003ca href=\"http://github.com/Pocket/Pocket-ObjC-SDK\"\u003ehttp://github.com/Pocket/Pocket-ObjC-SDK\u003c/a\u003e. If you use recommend adding the Pocket SDK as a git submodule of your project by running \u003ccode\u003egit submodule add git://github.com/Pocket/Pocket-ObjC-SDK.git \u0026lt;path\u0026gt;\u003c/code\u003e from the root directory of your repository, replacing the \u003ccode\u003e\u0026lt;path\u0026gt;\u003c/code\u003e with the path you'd like it installed to.\u003c/p\u003e\n\n\u003cp\u003eIf you use \u003ca href=\"http://cocoapods.org/\"\u003eCocoaPods\u003c/a\u003e, you can add the \u003ccode\u003ePocketAPI\u003c/code\u003e pod to your Podfile. Then run \u003ccode\u003epod install\u003c/code\u003e, 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.\u003c/p\u003e\n\n\u003cp\u003eThe project download includes the SDK and an example project.\u003c/p\u003e\n\n\u003ch3 id=\"step2:addthepocketsdktoyourproject\"\u003eStep 2: Add the Pocket SDK to your project\u003c/h3\u003e\n\n\u003cul\u003e\n\u003cli\u003eOpen your existing project. \u003c/li\u003e\n\u003cli\u003eDrag the SDK folder from the example project into your Xcode project.\u003c/li\u003e\n\u003cli\u003eMake sure the “Copy items into destination group’s folder (if needed)” checkbox is checked.\u003c/li\u003e\n\u003cli\u003eSelect 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.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cp\u003eThe SDK includes all necessary source files and does not have any other dependencies.\u003c/p\u003e\n\n\u003cp\u003e\u003cimg id=\"\" src=\"https://s3.amazonaws.com/pocket-assets/adding-sdk.png\" alt=\"\" title=\"Dragging the SDK to your XCode project\" /\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003cimg id=\"\" src=\"https://s3.amazonaws.com/pocket-assets/adding-security-framework.png\" alt=\"\" title=\"Security.framework is in the Link Binary With Libraries Build Phase\" /\u003e\u003c/p\u003e\n\n\u003ch3 id=\"step3:obtainaplatformconsumerkey\"\u003eStep 3: Obtain a platform consumer key\u003c/h3\u003e\n\n\u003cp\u003eWhen you register your app with Pocket, it will provide you with a platform consumer key. This key identifies your app to Pocket’s API.\u003c/p\u003e\n\n\u003cp\u003eIf you have not obtained a consumer key yet, you can register one at \u003ca href=\"http://getpocket.com/api/signup\"\u003ehttp://getpocket.com/api/signup\u003c/a\u003e\u003c/p\u003e\n\n\u003ch3 id=\"step4:addthepocketurl-scheme\"\u003eStep 4: Add the Pocket URL scheme\u003c/h3\u003e\n\n\u003cp\u003eOnce 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 \u0026#8220;pocketapp\u0026#8221; plus your application\u0026#8217;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 \u0026#8220;pocketapp42\u0026#8221;. \u003c/p\u003e\n\n\u003cp\u003eIf 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 \u003ccode\u003e[[PocketAPI sharedAPI] setURLScheme:@\"YOUR-URL-SCHEME-HERE\"]\u003c/code\u003e. To add a URL Scheme, create a block like the one below in your Info.plist, updating it with the app’s scheme:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003e▾ URL Types (Array)\n    ▾ Item 0 (Dictionary)\n          URL Identifier (String) com.getpocket.sdk\n        ▾ URL Schemes (Array) (1 item)\n            Item 0  (String) [YOUR URL SCHEME, like \"pocketapp42\"]\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003cp\u003eOr you can copy and paste the following into the XML Source for the Info.plist:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003e\u0026lt;key\u0026gt;CFBundleURLTypes\u0026lt;/key\u0026gt;\n\u0026lt;array\u0026gt;\n    \u0026lt;dict\u0026gt;\n        \u0026lt;key\u0026gt;CFBundleURLName\u0026lt;/key\u0026gt;\n        \u0026lt;string\u0026gt;com.readitlater\u0026lt;/string\u0026gt;\n        \u0026lt;key\u0026gt;CFBundleURLSchemes\u0026lt;/key\u0026gt;\n        \u0026lt;array\u0026gt;\n            \u0026lt;string\u0026gt;pocketapp9553\u0026lt;/string\u0026gt;\n        \u0026lt;/array\u0026gt;\n    \u0026lt;/dict\u0026gt;\n\u0026lt;/array\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch3 id=\"step5:configureyourappdelegate\"\u003eStep 5: Configure your App Delegate\u003c/h3\u003e\n\n\u003cp\u003eThe 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.\u003c/p\u003e\n\n\u003ch4 id=\"importthepocketapiheader\"\u003eImport the PocketAPI Header\u003c/h4\u003e\n\n\u003cp\u003eAt the top of your app delegate source file (and anywhere you call the PocketAPI object),  you\u0026#8217;ll need to include the PocketAPI header. At the top of your class you\u0026#8217;ll probably see other imports already. Simply add this line:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003e#import \"PocketAPI.h\"\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch4 id=\"setyourplatformconsumerkey\"\u003eSet Your Platform Consumer Key\u003c/h4\u003e\n\n\u003cp\u003eThe 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:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003e[[PocketAPI sharedAPI] setConsumerKey:@\"Your Consumer Key Here\"];\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch4 id=\"addamethodforthepocketurl-scheme\"\u003eAdd a method for the Pocket url-scheme\u003c/h4\u003e\n\n\u003cp\u003eThe 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:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003e-(BOOL)application:(UIApplication *)application\n           openURL:(NSURL *)url\n sourceApplication:(NSString *)sourceApplication\n        annotation:(id)annotation{\n\n    if([[PocketAPI sharedAPI] handleOpenURL:url]){\n        return YES;\n    }else{\n        // if you handle your own custom url-schemes, do it here\n        return NO;\n    }\n\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch3 id=\"step6:startsavingtopocket\"\u003eStep 6: Start Saving to Pocket!\u003c/h3\u003e\n\n\u003cp\u003eAt 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:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003eNSURL *url = [NSURL URLWithString:@”http://google.com”];\n[[PocketAPI sharedAPI] saveURL:url handler: ^(PocketAPI *API, NSURL *URL, NSError *error){\n    if(error){\n        // there was an issue connecting to Pocket\n        // present some UI to notify if necessary\n\n    }else{\n        // the URL was saved successfully\n    }\n}];\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003cp\u003eThe 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 [linkto:delegate or operation based methods].\u003c/p\u003e\n\n\u003ch2 id=\"managingaccountshandlinguserlogins\"\u003eManaging Accounts / Handling User Logins\u003c/h2\u003e\n\n\u003cp\u003eFollowing 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:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003e[[PocketAPI sharedAPI] loginWithHandler: ^(PocketAPI *API, NSError *error){\nif (error != nil)\n{\n    // There was an error when authorizing the user. The most common error is that the user denied access to your application.\n    // The error object will contain a human readable error message that you should display to the user\n    // Ex: Show an UIAlertView with the message from error.localizedDescription\n}\nelse\n{\n    // The user logged in successfully, your app can now make requests.\n    // [API username] will return the logged-in user’s username and API.loggedIn will == YES\n}\n}];\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003cp\u003eIt is also recommended to observe changes to the PocketAPI\u0026#8217;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.\u003c/p\u003e\n\n\u003ch3 id=\"callingotherpocketapis\"\u003eCalling Other Pocket APIs\u003c/h3\u003e\n\n\u003cp\u003eTo call other arbitrary APIs, pass the API\u0026#8217;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.\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode\u003eNSString *apiMethod = ...;\n PocketAPIHTTPmethod httpMethod = ...; // usually PocketAPIHTTPMethodPOST\n NSDictionary *arguments = ...;\n\n [[PocketAPI sharedAPI] callAPIMethod:apiMethod\n                       withHTTPMethod:httpMethod\n                            arguments:arguments\n                              handler: ^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error){\n    // handle the response here\n }];\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch1 id=\"acknowledgements\"\u003eAcknowledgements\u003c/h1\u003e\n\n\u003cp\u003eThe Pocket SDK uses the following open source software:\u003c/p\u003e\n\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/ldandersen/scifihifi-iphone/tree/master/security\"\u003eSFHFKeychainUtils\u003c/a\u003e for saving user credentials securely to the keychain.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/erica/uidevice-extension\"\u003eUIDevice-Hardware\u003c/a\u003e for creating a user agent\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch1 id=\"license\"\u003eLicense\u003c/h1\u003e\n\n\u003cp\u003eCopyright (c) 2012 Read It Later, Inc.\u003c/p\u003e\n\n\u003cp\u003ePermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u0026#8220;Software\u0026#8221;), 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:\u003c/p\u003e\n\n\u003cp\u003eThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\u003c/p\u003e\n\n\u003cp\u003eTHE SOFTWARE IS PROVIDED \u0026#8220;AS IS\u0026#8221;, 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.\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPocket%2FPocket-ObjC-SDK","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPocket%2FPocket-ObjC-SDK","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPocket%2FPocket-ObjC-SDK/lists"}