iOS Development - Abstract Protocol of App Architecture

iOS Development - Abstract Protocol of App Architecture

From the perspective of architectural design, an end, especially a mature end, should have its own specifications, ranging from page jumps and service requests to specific business functions such as generating orders, canceling orders, and viewing orders. On the one hand, after formulating a unified protocol, it can not only constrain the development behavior of developers in each business line, unify the code style, but also enhance the cooperation and cohesion of team members. On the other hand, after the unified development behavior, it is very helpful for adding new functions, fixing bugs, querying problems, etc., which greatly improves development efficiency.

[[214533]]

One of the most important functions of the App Architecture Group is to unify the App architecture, allowing business developers to shape end products in a unified architecture, with the mission of improving business development efficiency and ensuring business stability. Based on this principle, we have been exploring various skills related to App architecture over the past year. I have found that the protocol is a key technology that best reflects the significance of App architecture. Using and promoting the protocol well can double the efficiency of business development.

Generally speaking, the protocol types in an App can be arbitrarily divergent. As long as they can be reused, you can use the word "protocol" to describe them. Of course, we are all people with aspirations, and we should create some more general, more abstract, and more reusable protocols. For example, the url scheme in the iOS SDK is such a typical example.

iOS URL Scheme

URL Schemes is a mechanism provided by Apple to jump to system applications or other people's applications. It can also transfer data between applications to implement some specific functions. You can understand the URL of an iOS application in the same way as you understand the URL of a web page.

For example, WeChat’s URL scheme

  1. weixin://

WeChat Moments URL scheme format

  1. weixin://dl/moments

Doesn’t it look convenient?

In other apps, you can jump to the WeChat App (if installed) like this:

  1. NSURL *url = [NSURL URLWithString:@ "weixin://" ];
  2. [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
  3.           
  4. }];

Each application can create one or more url schemes of its own. You only need to configure the info.plist file, and then communicate between apps through the App Management Center [UIApplication sharedApplication].

Similarly, we can apply this idea to other abstract modules. In each abstract module, we use a protocol to specify its usage rules and supported functions. When it is open to the caller, as long as it follows the protocol rules and uses the API interface provided by the abstract module, it can call the module or use the services it provides.

From this, we can draw the following conclusion: To abstract a module using a protocol, two important components are needed: protocol + protocol management center.

General Protocol

  1. scheme://service/actor?params=\{\ "xxx\" :xxx\}&origin=xxx

In the App architecture, the page navigation framework is a very important component, which directly determines the page organization and style of the current App. A good page navigation framework can also allow the business side to have the best new page construction and page jump experience. From the perspective of the protocol, we can agree on a page jump protocol as follows:

Page jump protocol

  1. page:// action ?params=\{\}&origin=xxx
  2. // Jump to native page
  3. page:// goto ?params={ "page_name" : "xxxx" , "data" :{ "xxx" : "xxx" ,...}, "navi_type" :0|1, "anime_type" :-1|0|1|2|3|4, "success_callback" : "xxxxxx" , "failure_callback" : "xxxxx" }&origin=xxx
  4. // Jump to h5 page
  5. page://act_web?params={ "page_name" : "xxxx" , "data" :{ "xxx" : "xxx" ,...}, "navi_type" :0|1, "anime_type" :-1|0|1|2|3|4, "success_callback" : "xxxxxx" , "failure_callback" : "xxxxx" }&origin=xxx

The APIs that Manager needs to provide include:

  1. // Jump to native page
  2. // Jump to h5 page

Service Request Protocol

  1. // @TODO can continue to split
  2. service://modulename/servicename?params={}&origin=xxx

Bridge Protocol

  1. // bridge is a specific scheme, bridgename is the api supported by the bridge js library
  2. bridge://bridgename?module=xxx&method=xxx&args=\{\}&origin=xxx

<<:  Web Dev: 2017 highlights and 2018 predictions

>>:  What impact does big data have on mobile app development?

Recommend

"Understand operations and do marketing" - three steps to operational strategy

In the early days of mobile Internet , the earlie...

"What's my zodiac sign?" There's actually a national standard for this!

Does the zodiac sign of rabbit start from New Yea...

Is acrophobia just a fear of the body? You think it’s too simple.

Whether you are a mountain climbing enthusiast or...

2022 Lithium Battery White Paper: Lithium Battery Recycling, a Promising Future

1. Based on commercial reality, it is expected th...

The turning point is coming: What can we do to maintain the popularity of IP?

In 2016, the competition for IP became even more ...

Panasonic exhibits 0.45mm flexible battery: smaller than a credit card

The shape of most wireless devices is determined ...

An article to understand the principle of QR code

QR code has been applied in all aspects of life n...

How much radiation does the body absorb when taking a "film"? The truth is...

When at work: Computer radiation is very strong W...

Why is the image quality on Android not as high as on iOS?

I often see people asking: "Why are the pict...

This bouncing ball of meat is actually a "sea treasure"?

Review expert: Chen Yu, paleontological restorati...

It’s too late to drink coffee when you’re sleepy!

Coffee has always attracted much attention as a l...

How to write a crisis public relations plan?

Introduction: Behind every event, there is a trut...