CocoaPods one-click Integration of Third-Party login (Sina Weibo, qq, WeChat), cocoapods one-click

Source: Internet
Author: User

CocoaPods one-click Integration of Third-Party login (Sina Weibo, qq,), cocoapods one-click

Third-party login is a common feature of apps, and I have already written this feature two or three times... It is really painful to write similar code every time, and every time you need to add those dependent libraries and configure linkFlag or something according to the instructions, it is completely physical, so I always wanted to encapsulate this part of code for reuse later. Inspired by DWZShareKit, we thought we could use cocoaPods to add dependency libraries and complete the configuration. So we quickly put our previous ideas into action and wrote a library that integrates third-party login. The address is here: Workshop. (One-click integration is an exaggerated rhetorical method. It is still necessary to apply for an appKey to enter scheme or something ~) I. The idea is how CocoaPods can complete the configuration and how it works. So I can only talk about how I use it here. LXMThirdLoginManager. podspecIn this file, . PodspecThere are some descriptions of the Code s. libraries indicates that the pod depends on the official Apple library, which is similar to libstdc ++. a, libsqlite. a file; s. vendored_libraries indicates the user's a file, such as the libWeiboSDK of Sina Weibo SDK. a; s. frameworks indicates the apple framework on which the pod depends, such as UIKit and SystemConfiguration. vendored_frameworks indicates the framework that the pod depends on, for example, TencentOpenAPI of the qqSDK. framework; (other do not list one by one, see the specific CocoaPods Official Website: https://cocoapods.org/about) (another seems to be the reference of the document address: http://www.rubydoc.info/github/CocoaPods/Core/Pod/ Specification/DSL) to add all the files dependent on the third-party login SDK to the pod. When CocoaPods loads the pod, by the way, the libraries on which third-party logins depend will be loaded together. In this way, we do not need to configure each project once ~~~ CocoaPods will automatically add-ObjC linkerFlag, which is convenient ~~ But there are also disadvantages: 1. After each SDK is updated, it will not be known as soon as possible, so it cannot be updated as soon as possible; 2. It is because all the SDK files are included in this pod, as a result, this pod file is very large (about 6 MB), and it will take a lot of time to install it. Especially if the network speed is not powerful, the pod may not be able to run... 3. the method provided is relatively simple. If you want other functions, you still need to develop it by yourself, but the biggest purpose of this library is to save the time we configured !!! I am satisfied with it. 2. Code implementation as far as code implementation is concerned, we want to apply a design pattern similar to the engineering pattern here. I don't know if it is correct... It means that a unified Manager (LXMThirdLoginManager) is used as the unified portal for external calls, and a helper class is written internally for each login type (these classes provide a unified call interface ), complete the respective login logic, and then unify the method returned by the callback manager (Unified result class ). In this way, external calls are simple, and if you need to expand, you only need to add a new Login type and a helper class, without affecting the use of other types. Let's take a look at the code. You must at least implement the Code on your own. 3. tucao 1. Sina Weibo must have the same bundleID of the project and the bundleID registered on its development platform before logging in... To write a new demo, you have to change the bundleID... 2. The created mobile app has the login permission only after being authenticated. It takes only one year to authenticate the 300 pieces, and you are not allowed to register a game .... 3. For qq qualification certification, I still need to upload photos of my ID card. Even if I want my ID card, I need both sides... 4. qq seems to have to add bundleDisplayName to the info. plist file. It seems okay if I didn't write it... Is this document too long? 5. There is no available appKey and appSecret in the demo. You can't blame me for it. You can't use it yourself, and you can't disclose it to your company... 6. Be physically tired... Reading documents is also a kind of physical activity...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.