@[toc]

The introduction

Welcome to # publicid :iOS Reverse iOS Payments Project Practices

This article provides an outline of what you will learn and serves as a guide to the iOS Payments Project practice column.

The blue words in the text are portals, click to enter

This column takes actual practice as the clue, and gradually goes deep into each link of iOS development, mastering basic functions commonly used in payment APP (including demo source code), creating a complete native client workflow, and improving engineering coding ability and thinking ability.

Suitable for iOS beginners, basic functions that will be used in the development of payment app scenarios

The overall outline module of this column

1. Interface construction (cashier desk, electronic signature, shopping cart, calculator, product details page, popbox of user Agreement and Privacy Policy, feedback page)

2. Receiving and payment (voice broadcast, parameter signature)

3. OCR (self-defined camera for bank card/ID card information identification)

4. Encapsulate the UnionPay interface protocol, optimize network request security, and protect the sensitive logic

5. Process user input content (amount/mobile phone number, etc.)

6, [encapsulation of rich text API, using block to achieve chain programming] (Block wit: combining the advantages of block and method to achieve iOS chain programming)

7. Code management: CocoaPods

8, picture compression: [solve the problem of blurred pictures after compression]

9. IOS test: Modify latitude and longitude information through GPX file (simulate the location of iOS devices)

10. Common iOS animation [fixed-point zooming popover] is implemented by using the anchorPoint

The Popup menu supports popover operations such as placing/placing commodities, printing commodity price tags, editing commodity information and synchronizing online stores

12. Navigation: Install MASConstraint and remove it. Application scenario: display and hide the navigation view flexibly

13, iOS upload pictures (support deletion and adding) (use UICollectionViewCell, UITableViewCell, and navigation. Using MVVM implementation.)

14, Bluetooth printing: iOS [print price tag template and print receipt template, automatic connection to the recently used printer] (for Jiabo GP-2120TU model) contains a complete demo source

15, [iOS APP internationalization switch] 1, string localization, 2, custom parse localization string tool class LanguageManager, 3, example: login interface switch English.

My introduction

XXX Information Technology Service Co., LTD.,iOS senior engineer, responsible for the development of xxxNative client core components. Good at iOS, iOS8 years of development experience, once participated in the development of China Mobile and package projects.

I, view,

1.1 User Agreement and Privacy Policy dialog box

  • IOS custom view: Popbox of User Agreement and Privacy Policy (including hyperlink properties)

1, the principle of the article: blog.csdn.net/z929118967/…

2. Function usage: Click the text on the right upper shelf of demo to switch between Chinese and English

3. Implementation steps of the popbox of User Agreement and Privacy Policy:

3.1. Customize TextView Using the contents of the rich text attributes attributedText (including the underline NSUnderlineStyleSingle, hyperlinks NSForegroundColorAttributeName NSLinkAttributeName, color and other information)

3.2, method of implementation agent textView: shouldInteractWithURL: inRange, click on the hyperlink

1.2 Electronic Signature

  • IOS Electronic signature Part 1 [Core principle: Rotating a specific screen] Application scenario: Collecting electronic signatures. The signature interface is in landscape mode and other pages are in portrait mode. Clearing overwriting, flexible control of prompt information, and viewing merchant agreements are supported

1, the principle of the article: kunnan.blog.csdn.net/article/det…

2. Functions: Collect electronic signatures, support the signature interface to be horizontal and other pages to be vertical, clear rewriting, flexible control of prompt information, and view merchant agreements

3. Core principle: Only rotate certain screens

4, core steps: 1, viewWillAppear set landscape 2, viewWillDisappear set vertical screen

5, simple usage: block callback electronic signature picture

1.3 Product Details page

  • UICollectionView adaptive case explanation: 【 product details page 】 (core principle: in accordance with the original width and height ratio of the picture to display all the content of the picture, and automatically adapt to the height) complete demo source code

1, the principle of the article: kunnan.blog.csdn.net/article/det…

2. Application scenarios: product details page and interface that needs to display a large number of pictures

3. Core principles

3.1) Shrink according to the original aspect ratio of the picture

3.2) Height adaptation of UICollectionView

1.4 Upload image view encapsulation [delete and add support]

The demo source code download: https://download.csdn.net/download/u011018979/15868813

1, article: kunnan.blog.csdn.net/article/det…

2. Application scenarios: uploading and displaying multiple pictures, such as processing and releasing commodity pictures by venture merchants

3. Effect picture:

4. Technical features: UICollectionViewCell and UITableViewCell controls will be used to construct the navigation framework, and MVVM structure will be adopted.

5, my other SDK like pod ‘KNPodlib’

1.5 Check the certification materials of venture merchants. Slide to switch pictures

//cloud.mo4tech.com/images/ldWYtlmLrJXYtJXZ0F2dtA3YmBnYmFTdzsWL2xGc05HOxIGMjNWYllTZmVWO2UTOlNzN0QzNzUjN2kTY5YTNk9CcjZGciZWM1NzatkWLuNWLz9Gdv02bj5yZtlWZ0lnYu4WaqVWdq1yMw9yL6MHc0RHa/d19fbf95815c6bf2e12debacd2685ed6.image

IOS development commonly used animation (zooming popover) application scene:

1. Right drop-down operation menu of member details

2. The drop-down menu on the right of the browser3. Original Text:Kunnan.blog.csdn.net/article/det…4,The demo download address: https://download.csdn.net/download/u011018979/16092830

CSDN Warehouse Demo Address Github warehouse address

5. Related articles: use the anchorPoint to achieve

1.7 iOS lottery turntable: probability lottery algorithm & turntable algorithm & main view of the implementation ideas

iOS draw wheel: The probability lottery algorithm & rotary algorithm & itself the realization of the main view of thinking (CSDN download complete Demo) from https://download.csdn.net/download/u011018979/16651799

Article: kunnan.blog.csdn.net/article/det… Principle: use CoreGraphics for custom turntable drawing video: live.csdn.net/v/158749

1.8 Custom camera (bank card/ID card recognition OCR, rectangular edge recognition)

  • IOS ID card front and back camera (with shooting area frame, translucent mask layer, support to click the screen focus, automatically cut out the required size) _ ID card copy frame is not obvious

1, the resources download: https://download.csdn.net/download/u011018979/14045495

2, the principle of the article: kunnan.blog.csdn.net/article/det…

  • Rectangular edge recognition

    IOS Document Scanner: Rectangular edge detection CIDetectorTypeRectangle

From CSDN download Demo source: https://download.csdn.net/download/u011018979/19260280

1. Application Scenarios: In order to improve user experience, edge detection will be used in OCR identification scenarios

2. Principle: Edge detection can be carried out by CIDetector under the native CoreImage framework. After identifying the edge, CAShapeLayer will be used to draw and display the edge

Principle 3, article: kunnan.blog.csdn.net/article/det…

  • Identification card

From CSDN download Demo source: https://download.csdn.net/download/u011018979/19265912

1. Function: it can automatically and quickly read the information (name, gender, nationality, address, ID number) on the second generation of Chinese ID card and intercept the id card image

2. Application scenarios: COLLECTION of ID card number: online application of credit card, entry of merchant, real-name authentication

3. Principle: 3.1. Customize the camera and use the third-party library SDK LibexidCardios for identification

3.2. Add a custom scanning interface (with a hollow window in the middle and a scanning line moving back and forth)

3.3, face small box detection: whether the face area is in the face small box, if in, that the user does put the ID head in this box, then this frame ID image size is just right and complete, then capture the frame, you get a complete ID screenshot.

Principle 4, article: kunnan.blog.csdn.net/article/det…

  • Scanning bank card identification information:

From CSDN download Demo source: https://download.csdn.net/download/u011018979/19268420 1, function: scan card identifying information (bank name, bank card number) and bank card image

2. Application scenarios: scenarios for filling bank card numbers quickly, such as merchant entry and real-name authentication

3. Principle:

3.1. Customize the camera and use third-party libraries SDK LibexBankCardios. a and libbexbankcard.a for identification (unlimited identification times, free)

3.2. Add a custom scanning interface (with a hollow window in the middle and a scanning line moving back and forth)

Principle 4, article: kunnan.blog.csdn.net/article/det… 5. If you cannot download the Demo, please pay attention to the official number: [iOS Reverse] to obtain it

IOS custom camera for bank card/ID card information identification scheme

1, CSDN download demo source code from https://download.csdn.net/download/u011018979/19359759

2. Principle: The self-defined camera collects bank card pictures and invokes SDK/API for OCTR recognition

Address: 3, article kunnan.blog.csdn.net/article/det…

4. Application scenarios: real-name authentication, bank card binding, credit card online application

5, thinking

5.1, custom camera identification card/id information of the payment scheme: after transfer CVImageBufferRef UIImage, can be directly call third-party interfaces OCR kunnan.blog.csdn.net/article/det…

A and libbexBankcard. a third-party libraries are directly used to analyze the bankcard number information in CVImageBufferRef, and then obtain the bank name according to the card union rules

1.9 Necessary module of cashier APP: iOS discount calculator

Exact calculation of expressions using NSDecimalNumber (calculation of string mathematical expressions)

1, the principle of the article: https://kunnan.blog.csdn.net/article/details/84769730

2. Background: When I used NSExpression to calculate expressions, I found a problem: it is not accurate to the decimal number (the accuracy of 1+65 and 65+1 is different).

3. Solution: NSDecimalNumber is used for calculation

4, download address: https://download.csdn.net/download/u011018979/14038508

1.10 the address book

IOS Processing Language Tool CFStringTransform: Intelligently Processing user input, classic Application Scenarios [Index]

  • Download address book demo source code from CSDN

Download.csdn.net/download/u0… 1, principle: through the user input content, using CFStringTransform, can easily achieve a universal search index

2. Features: Search content can be multilingual

3, article: https://kunnan.blog.csdn.net/article/details/109603377

1.11 Limit the number of characters to be entered in the text input box

  • From CSDN download demo: https://download.csdn.net/download/u011018979/15842447

1, the original: kunnan.blog.csdn.net/article/det…

2, main function: limit the text input box to enter a specific number of characters, text length calculation rules: Chinese accounted for 1, English can be converted to ASCII accounted for 0.5

3, features and functions: iOS limits the input of associative strings, Chinese characters account for 2 characters, English account for 1 character, solve the bug caused by the association of Chinese and English switching input method

4. Demo requirements: The input box for risk merchant processing interface is limited to 100 characters

5, Private Repositories: github.com/zhangkn/Res…

6. The Demo project is implemented by MVVM

1.12 iOS Product Category Selection View

Download address: https://download.csdn.net/download/u011018979/19775162

The article addresses: kunnan.blog.csdn.net/article/det…

Video address: live.csdn.net/v/167208 Application scenario of commodity Operation Category Selection view:

1. Select product categories when releasing products; 2. Merchants select business categories when entering products; 3

When publishing an item, the requirements view of the category selection screen is divided into two sections.

1. Upper part: the selected category information is displayed, and the corresponding hierarchical category information is clearly listed from the top (suspension). When clicking on the category, the displayed category information in the lower part is switched to the information of the same category for selection.

2, the next part: display the information of available categories (support scrolling to select categories)

Supports data clearing

II Voice broadcast & Internationalization

2.1 iOS12.1 The solution that voice broadcasting cannot be performed in the background or killed

IOS NotificationServiceExtension implementation VoiceBroadcast 【 app is in a state of background/killed still language can be broadcast 】 iOS12.1 was killed in the background or above can’t speech solutions

———————————————— Copyright notice: This article is the original article of CSDN blogger “# public account: iOS Reverse”, in accordance with CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement. 1, the original link: blog.csdn.net/z929118967/…

2, CSDN download resources source: https://download.csdn.net/download/u011018979/14026303

2.2 Internationalization switching within the APP

From CSDN download demo internationalization switch within the iOS APP 】 【 source: download.csdn.net/download/u0…

Article: kunnan.blog.csdn.net/article/det… Principle:

1. Customize the tool class LanguageManager to parse localized strings

2, the implementation of in-application switching language effective technology: destroy the root controller, re-enter once

Localizer string specifies the order of arguments

III Bluetooth printing commodity price tags, transaction receipts

  • “Print commodity price tag and print transaction receipts” demo source: https://download.csdn.net/download/u011018979/14920529

1. Application scenarios: printing commodity price labels and transaction receipts

2, features: automatic connection to the recently used printer, unified processing of Bluetooth status

Principle 3, article: kunnan.blog.csdn.net/article/det…

4. The problem to be solved: the problem of RMB ¥garble private

IV. IOS security Resources

4.1 Parameter Signature

Signature of request parameters on iOS APP side: [Request parameters are sorted, spliced and encrypted according to ASCII codes from smallest to largest] (implemented recursively)

1, from CSDN download demo address: https://download.csdn.net/download/u011018979/15483107

2, article: kunnan.blog.csdn.net/article/det…

3. Application scenarios: Prevent request parameters from being maliciously modified

4.2 Protection Schemes for Sensitive Logic

Example: Js gets device and signature information from local methods based on key (full demo)

OC local method encapsulates the signature method, the signature method is implemented in C language, and the function name is hidden in the structure, stored in the form of function pointer members, so that after compiling, only the address is left, the name and parameter list are removed, and the reverse cost and attack threshold are increased.

The 2021-04-14 17:28:28. 762113 + 0800 SignWithjsKey [23919-2084235] getGyqAppParams: {" api_version ":" v1.1.4 ", "appid" : "3", "time" : "1618392508", "operator" : "China telecom", "user_id" : "https:\/\/kunnan.blog.csdn.net \ /"," .vn ":" 1.0 ", "device_id b8eeff0f1612d4b9fba63ba7b47dbf27" : ""," channel ":" default ", "device_name iPhone8" : ", ":" 1 ", "the OS iOS," "sign" : "b2ad581d2e30730f3aed506fc7593957 openudid", "" :" 0 dce01d7424ac836d33ef49e20019e920e847e96 ", "token" : "# public no. : IOS reverse ", "root", "1", "idfv" : "d8e400c711 a9 - D089-4021-82-65", "height" : "1334", "width" : "750", "xyz" : "0.006973, 0.007675, 1.009369 Os_version ", ":" 14.0 ", "network" : "no_network", "vc" : "1", "idfa" : "- 3693-4940 - c59e53fa55 BEAD - 93"}Copy the code

From Demo:https://download.csdn.net/download/u011018979/16751837 CSDN download

1. Application scenarios: Signature functions

2, principle: in order to improve the security of the code, you can use the function name hidden in the structure, stored in the form of function pointer members. After compiling, only the address is left, the name and parameter list are removed, and the reverse cost and attack threshold are raised.

3, article: kunnan.blog.csdn.net/article/det…

4.3 Intercepting all network requests based on NSURLProtocol

From CSDN download demo resources: https://download.csdn.net/download/u011018979/16768533

1, article: kunnan.blog.csdn.net/article/det…

2. Application Scenarios:

2.1. Customize the HTTPHeaderField for the request header

2.2, against NSURLSessionConfiguration agents set up IP and port, make some special request custom tunnel IP and port

2.3. Packet level encryption for network request data: NSURLProtocol is used to automatically monitor HTTP requests and encrypt and decrypt them. Through [NSURLProtocol registerClass: [NetworkInject Class]]; A custom NSURLProtocol class is injected

3, principle: use NSURLProtocol interception HTTP request based on NSURLProtocol implementation of iOS application bottom all network request interception (including web ajax request interception [WKWebView is not supported]);

4, features: HTTP-DNS solution, effectively prevent DNS hijacking. DNS resolution is performed directly from the local or specific server address, which is a measure to avoid DNS hijacking github.com/zhangkn/KNU…

V, reverse

5.1 the IPC

IOS AppStore Search optimize Inter-Process Communication Depends on RocketBootstrap

1, download address: download.csdn.net/download/u0…

2, article: https://kunnan.blog.csdn.net/article/details/114693546

3, Purpose: To ship RocketBootstrapD to my deb so that every deployment is not updated from bigBoss source.

IOS AppStore Search Optimize inter-Process Communication By Rrocketbootstrap ———————————————— This article is an original article BY CSDN blogger “# public account: iOS Reverse”, in accordance with CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement.

The original link: blog.csdn.net/z929118967/…

5.2 Analyze how to call pTrace and hook pTrace

From CSDN download the complete Demo: https://download.csdn.net/download/u011018979/15834414

1, download.csdn.net/download/u0…

2. Private warehouse

3, article: blog.csdn.net/z929118967/…

4, remove the ptrace thread:

4.1 When the program runs and the attached process of debugServer *:1234 -A BinaryName appears SegmentFault 11, it generally indicates that the program calls pTrace internally.

To check whether ptrace is called, you can use debugServer -x backboard *:1234 /BinaryPath (here is the full path), and then use the symbol breakpoint B ptrace, c to check the location of the first line of ptrace. Then p $LR finds the return address of the function, and calculates the original address according to the ASLR offset of image list -o-f. Finally, find the code that calls pTrace in IDA and analyze how to call pTrace.

4.3 start hook pTrace.

5.3 Real-time communication scheme between processes

Local socket (for real-time communication between extension and container applications)

1, download address: download.csdn.net/download/u0…

2, the principle of the article: blog.csdn.net/z929118967/… Local Socket scheme (TCP) is used to create the server and client to achieve the communication effect.

3. Application scenarios: Solve the real-time communication problem of extension and container applications

VI. Click the tabBar button in iOS to refresh the interface

  • video

live.csdn.net/v/156107

//cloud.mo4tech.com/images/ldWYtlmLrJXYtJXZ0F2dtA3YmBnYmFTdzsWL2xGc053MkNGNlFjY2YzYyYGZ1YjYzYTZ0MmNjBzM1UjMmVDO48CcjZGciZWM1NzatkWLuNWLz9Gdv02bj5yZtlWZ0lnYu4WaqVWdq1yMw9yL6MHc0RHa/8e02c122a7752bd55a7d2236b9244340.image (Block wit: combining the advantages of block and method to achieve iOS chain programming)

1, the principle of the article: kunnan.blog.csdn.net/article/det…

Block the use of: combined with the advantages of the block and the method realizes the iOS chain 2, functional programming: mainly for paragraph styles NSMutableParagraphStyle and rich text NSMutableAttributedString encapsulation, improve development efficiency. 3, download address: Download.csdn.net/download/u0…

see also

CSDN blog expert (rising star creator in mobile development) : kunnan.blog.csdn.net/ public account: iOS reverse (code4iOS)