Third-party open source libraries commonly used in iOS projects

Source: Internet
Author: User
Tags sqlite database

1. Third-party open source libraries used by the project

http://github.ibireme.com/github/list/ios/collated the more commonly used iOS third-party components, as well as statistics on GitHub.

The project uses Cocoapods (similar to Maven in Java) to manage the commonly used third-party libraries, some special separate references, and the following are some of the more useful ones.

(1) Afnetworking

Currently the recommended iOS network request component, the default network request is asynchronous, through the block callback to the return data processing.

It is important to note that afnetworking the contenttype requirements returned by the server are stricter, and only the return of Application/json is supported by default. Therefore, you may need to add support for text/html returns, or you may not be able to get the returned data.

Another is the file upload, here is recommended to use the second type:

1
2
[FormData Appendpartwithformdata:name:];
[FormData AppendPartWithFileData:name:fileName:mimeType:];
The first one only needs to pass in the table sole name and the file stream, the source code is based on the file stream to obtain the corresponding file name and type, and then call the second method. But the landlord encountered the use of the first method, submitted after the background to determine non-file upload, unable to obtain file stream. Also, if the background is based on the file suffix file type, then the first kind is not available.

The afnetworking is asynchronous, or you can use a synchronous network request method.

(2). FMDB

The SQLite database operation is encapsulated, and the demo is relatively simple.

(3). Mbprogresshud

It is also a common component of the iOS project to show transitions, such as loading before a network request, and the end of the network to hide loading. Recommended encapsulation in Baseviewcontroller, all Viewcontroller inheritance can be used.

(4). Mjrefresh

This is a podcast Li Mingjie Teacher's work, his OC basis is to watch his video half a week on the basic win. Mjrefresh is mainly used for refreshing operations, providing common refresh operations, as well as refreshing animations, which are very useful. It is recommended that you encapsulate the method in Baseviewcontroller so that when you modify the refresh operation, you only need to change one copy. (previously used by the old version of Mjrefresh, only support the normal refresh, not support animation, later updated version of the larger changes, the old method has been deprecated, so it is better to use the package base class, easy to modify later)

(5). Sdwebimage

is also the most commonly used iOS component, the user loads the network picture, can cache to the local. Presumably, after the first load, the file name is cached locally based on URL encryption, and if the picture is loaded again, it is loaded directly from the local page. It's easier to use. Here also share a problem encountered, first load a small map from the network, and then a small image as a bitmap, and then load a large image from the network.

1
2
3
[ImageView Sd_setimagewithurl:[nsurl urlwithstring:imageurlstring] placeholderimage:defaultpostpic];
[ImageView Sd_setimagewithurl:[nsurl Urlwithstring:_bigimageurlstringarray[i]] PlaceholderImage:imageView.image Options:sdwebimagedelayplaceholder completed:^ (UIImage *image, Nserror *error, Sdimagecachetype cacheType, NSURL * ImageURL) {
}];
(6). Rdvtabbarcontroller

A Tabbar component, can easily set the bottom menu text picture, click Effect, Little red dot hint and so on.

(7). Toast

Similar to the Android toast hint effect, encapsulated in Baseviewcontroller, where needed to prompt.

(8). Xmppframework

iOS's only XMPP class library, the author added the XEP-0198 protocol support (stream management for XMPP disconnection) last August, but cannot download to the latest version when it is updated via pod, perhaps 0198 is not perfect enough to be a full version.

(9). Tpkeyboardavoiding

The user's keyboard pops up to automatically calculate the height for screen scrolling operations.

(10). Amr

Do instant Messaging audio processing, currently our Instant Messaging uses a recording file that is M4A for easy web-side audio playback.

(11). Tqrichtextview

Used to display Rich text view controls, emoticons for instant messaging, and Rich text display of resource reviews.

(12). Csgrowingtextview

Use as an Instant Messenger text box and comment text box to display multiple lines of input.

(13). Mjextension

Li Mingjie is also the work of the teacher, for the use of JSON to model, a bit similar to the Java Google Gson. Conversion efficiency is said to be very high, the use is relatively simple, as long as the front and back of the agreement, JSON directly into the model. An iOS friend who has worked for years says that a project is primarily about managing the model layer, and he recommends mantle. MJ, however, is more lightweight and easier to use.

3. Introduction to Tools and plugins

Xcode

The official tool for iOS development, there is no other choice. Some of the features are really handsome, like Stroyboard's drag-and-drop event bindings. Uncomfortable place is no code formatting, another click Method, may run to another class!! In addition, the left side of the directory will not automatically change, to locate the corresponding file, need command+shift+j

SimPholders2

You can quickly find the appropriate sandbox directory for the simulator, and the right top toolbar has a button similar to close when it launches, showing several recent applications and clicking on the corresponding sandbox directory.

Vvdocumenter-xcode

Xcode tools,///Generate note templates, Xcode This feature does not give integration, alas.

The other basic is not introduced, and some are not very useful. SVN can use the Cornerstone,git can use Sourcetree,sqlite can use the SQLite Professional (just a fee, free to view only), you can also use the Firefox browser SQLite plugin.

4. Integration of the League of Friends

Friends Alliance, provides a one-stop solution for apps and applications. The company last mobile project used to the Friend Alliance push service, this project, also used the sharing, third-party login function, oneself also participated in the relevant integration. Friends of the league's developer documentation is relatively complete, encounter problems can contact customer service or to the Friends of the Forum to find solutions.

(1). About push

iOS push is divided into local push and remote push, local push refers to the local pop-up information, the other is remote push, when the app does not start, you can also receive the relevant push information. Our project is not using local push, it is using the Friend Alliance remote push. Includes messages (chats) and notifications (user information notifications). Users in the chat process, the phone in addition to send instant messaging, but also call the background interface, send Friends League push. Another user's posts, comments, concerns, likes and so on will be transferred from the background to the push of the Union.

Friends of the Alliance push (another domain name) including unicast, multicast, and broadcast, wherein the broadcast limit of 3 times a day, you can and friends to increase the number of applications, and other non-limited number of times, the current view of unicast speed is very fast. Using Friends League push, you need to create a new two push certificate in the Apple Developer account, submitted to friends League (Friends of the league has detailed documentation, can be consulted). Can be in the Friends of the Union backstage, the test equipment Devicetoken added to the Friends of the league push the backstage, from the Friends of the alliance backstage launch push. (Requires 64 tokens, need to be calculated by method, directly in Xcode or ituns to get token not)

Push the approximate process is that the mobile phone in the first launch of the app when the push service, mobile phone in the launch of the app, registered Friends of the Alliance service, while the Devicetoken submitted to their own backstage, the backstage can be in need to hold the devicetoken to adjust the push interface, Friends of the alliance to launch the Apple push service, so that the corresponding device received remote push information.

(2). About third-party login and sharing

This piece is in the social sharing of Friends League, which provides a more comprehensive document. We recommend that third-party sharing modules do not have their own special design, you can make the default sharing module (our project's share module itself has been designed, including the collection, so the entire block requires a custom write UI and write sharing code). About Friends of the third party login and sharing needs attention, QQ and login sharing, all need to install the app on the phone, AppStore audit card This, so need to determine whether the phone installed apps, hide the icon without the app installed, This alliance's SDK already has the relevant judgment method (should be the Friend Alliance integrates QQ and SDK,QQ and the SDK to provide the Judgment method).

Third-party login sharing requires a developer account to be registered with the relevant platform. Developer account (note not a subscription number) third-party login needs to pay to open, can support and friends to share. QQ developer account can support QQ and QQ space sharing (QQ microblogging seems to need Weibo developer account). Sina Weibo needs Weibo developer account. QQ Share development phase need to add test account to the developer account friend to test, Weibo is similar.

Third party login himself encountered the QQ prompt is not the latest version of the text, in the Friends of the Forum found a solution.

Third-party login, our project integrates QQ, Sina Weibo login. Three platforms can obtain the user's Screen_name (user name), and the corresponding platform unique ID, which QQ and are OpenID, Sina is the UserID.

Third party sharing, documentation provides sharing pictures, videos, voice. If you are sharing URLs, you need to set up a shared address for the corresponding platform, refer to the solution, such as

1
2
3
4
[Umsocialdata defaultdata].extconfig.qqdata.url = Shareurl;
[Umsocialdata defaultdata].extconfig.qzonedata.url = Shareurl;
[Umsocialdata defaultdata].extconfig.wechatsessiondata.url = Shareurl;
[Umsocialdata defaultdata].extconfig.wechattimelinedata.url = Shareurl;
In addition to share to the QQ space, must designate a picture, otherwise cannot share success.

Third party sharing recommendations encapsulated into a class, our project is a few detail pages are shared, comments, reports, collections, like and other features. Encapsulated in a basedetailviewcontroller, the related page inherits, and the corresponding resource type is passed in, and only one copy of the code is maintained.

5. Instant Messaging

There are third-party solutions on the instant communication networks, such as the ring letter, the cloud and so on. We are our own XMPP server, the server used by the Tigase, previously written related to the blog, their own last year also did the corresponding Webim. A period of time to see the ring Letter Webim SDK, the use of Strophe JS class library, related to the implementation of the same as ours, but their own setup XMPP will encounter a lot of problems, such as lost messages! So if you want to implement IM more quickly, we recommend using a third-party solution.

The lost message on the mobile side is probably like this. A and B communication, a sent a message to the server, the server sent to B, but B network is not good to drop, and the server did not know that B exited (b normal exit will send the server offline notification), so the message is lost. XMPP has the XEP-0184 protocol (message receipts), A to B messages, a line of code in the body of the message (requesting a message receipt), when B receives a message and sends a receipt to prove that I received. Later XMPP has a xep-0198 protocol (flow Management), fast heavy chain after disconnection, while judging a certain time to receive the message, write the message offline message, reduce the loss of messages. However, there may be a complex network situation, coupled with various uncertainties, there will be lost messages. At present, the more reliable method is to save all the chat record, from the mobile phone to the database according to the point of time to pull the message, as long as the messages sent by others will not be lost.

The Instant Messenger module has been changed and is also a reference to some of the previous developers ' suggestions. For example, when the user returns home, disconnected XMPP connection (iOS into the background, only 5 seconds of processing time, the special method can be extended to 10 minutes, if the memory is not enough, the app will be killed at any time). So when you go back home, you disconnect and then connect to the app. At the same time the use of the state, there is heartbeat detection, determine whether to stay connected.

Considering the particularity of iOS, we have adopted the method of XMPP and remote push both, and the message is handled the same way as the XMPP message body, which is pushed by the custom message body. User Chat sends XMPP message at the same time also call our message push interface to pull the union push (push can set expiration time, avoid special circumstances, push delay, chat ended before receiving push). One is to solve the push receive when the iOS app is not started, and the other is to resolve the problem of XMPP drop message.

About push, there are two methods in Appdelage, one is to receive push in the use, do not prompt, will process the push information directly. In addition, the program is non-use status, received push, will be prompted, you can click the push message into the app, get this push message push message (need to note that Click Push Launch app to get information when the view has not loaded, the message can not be processed immediately).

Android because it is the real background, you can keep running in the background, regardless of whether you receive the XMPP message or the Friend Alliance push, you can handle it yourself, and then play a local push (there are drawbacks, if the Android program killed, you can not accept messages and push). iOS because the background is not controllable, so push the use of remote push, access to the app connection XMPP to receive all offline messages (do not guarantee the Friendship League push can guarantee timely). Of course, most of the normal situation, the network situation is relatively good conditions, the real-time received the XMPP message or remote push. We are not QQ and, as long as the user to ensure that the data to maintain consistency on the line (so QQ and is Diao AH).

Based on the feedback from the test, the iOS app has a somewhat improved messaging situation than the previous application. Further observation of the specific situation.

Our instant messaging also includes voice and images, with an HTTP solution (XMPP also supports binary transmissions, but no one is expected to do so). The specific process is to upload the attachment to the attachment server to the address of the attachment server, and then encapsulated into the message body. When the receiving party receives the message parsing, it gets the corresponding resource from the attachment server and loads it locally. At the same time, some real-time operation such as shielding, unblock, etc. will also be sent XMPP, the first time both sides updated status.

Third-party open source libraries commonly used in iOS projects

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.