Applet Support Open mobile app What the hell is going on?

Source: Internet
Author: User

Objective

From the official Apple public platform article "applet Support Open mobile app", the applet has added two features:

    1. Support to open mobile apps
    2. Title bar Area Open Custom

For the second function, the developer can customize the color style of the Applet menu bar, customize the caption area outside the Applet menu as needed, such as setting the color of the caption area. Here's a look at the features that support opening a mobile app.

Support to open mobile apps

At first glance actually a bit of a headline party behavior that supports opening the mobile app?
What reminds me is that I can open any mobile app with a small program? (The answer is NO)
Can I open my own app? (The answer is open in a restrictive way)
Can I open the browser that comes with the system? (The answer is NO)
Is it possible to open a third-party mobile app? (The answer is NO)

In fact, the applet opens a mobile app with a hard-to-use requirement: A page that is shared from a mobile app to a applet that supports opening the source app when the user accesses it. let's take a closer look at this request.

Most programs have a sharing feature, and what we often do is share a picture, a text, or a URL link that you can share with friends (including groups), a circle of friends, or add to a personal collection, as follows:

We can also share small programs,

Above is a Rob ticket software (wisdom) to share a small program, friends can click the applet to help speed up. According to the official article, if there is a button to share the applet, the following is achieved:

<button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">打开APP</button>

Then when you click this button, the source app will open. In other cases it cannot be opened, here is a diagram of whether a mobile app can be opened:

Here the applet gives a scene value concept, only the scene value is 1036 (there is also a status value of TRUE or FALSE, it determines whether the app can be opened.) The scene value is 1036, the status value is True) applet, to be able to open the source app, that is, the applet can not open any app, can only jump back to the app to share the applet card. The official document also explains the logo:

In the life cycle of the applet, the initial value of this state is false, and then varies with each opening of the applet, whether it is started or cut to the foreground:
1. When the applet is opened from 1036 (App sharing message card), the status is set to True.
2. When the applet is opened from 1089 (Chat main screen dropdown) or 1090 (long press the top right corner menu of the applet to call out the most recent history), the state remains the same, that is, the value of that state when the applet was last opened.
3. When the applet is opened from a non-1036/1089/1090 scene, the status is set to False.

For the second, 1089 and 1090 that, my understanding is that the applet is similar to the mobile app, it does not close, but in the background, so 1089 and 1090 open applet just put the applet to the foreground, so the small program state unchanged. If true, the mobile app can also be opened.
The above is the introduction of the applet to open the mobile application, next look at the specific code implementation.

Code implementation sharing applet open mobile app (iOS version, Android similar)

The first thing to do is to create a new project, and then integrated sharing, how to integrate can be found in the official website integration document, after integration, add a button on the page, triggered by the implementation of the following:

-(Ibaction) Opensmallprogramaction: (ID) Sender {//share the implementation of small programsWxminiprogramobject *wxminiobject = [Wxminiprogramobject object]; Wxminiobject.username =@ "gh_*************"; Wxminiobject.path =@ "Pages/index/index";//Wxmediamessage *message = [Wxmediamessage message]; Message.title =@ "I'm a little program"; Message.description =@ "I'm a small program to test open apps";        Message.mediaobject = Wxminiobject;    Sendmessagetowxreq *req = [[Sendmessagetowxreq alloc] init];    req.message = message;    Req.scene = wxscenesession; [Wxapi Sendreq:req];//original to do share realization//Sendmessagetowxreq *req = [[Sendmessagetowxreq alloc] init];//Req.text = @ "shared content";//Req.btext = YES;//Req.scene = wxscenesession;//[Wxapi sendreq:req];}

Is this the way all the apps can share the applet using the above implementation? The answer is in the negative. Look at the official document saying:

The mobile app sharing feature supports applet type sharing and requires that the app and applet that originated the share be part of the same open platform account. Support for sharing applet type messages to friend sessions, "share to Friends" and "favorites" is not supported.

In other words, small program sharing is limited:

    1. The app and applet that started sharing are part of the same open platform account
    2. Only support sharing applet type message to friend session (Sendmessagetowxreq Scence only supports wxscenesession)

After testing, an account cannot register both an open platform and a public platform. In other words: If your account is registered with an open platform, then the account cannot be re-registered on the public platform.

The open platform is the mobile app.
The public platform is a small program.

What the official says is that the same open platform account is not an account with both the app and the applet (because the applet was developed on a public platform). After opening the Open platform page, the first article will understand:


If you want to share the applet within the mobile app, you must bind the applet under the Open platform account where the app resides, so that you can share the applet in the app. This is the official app and applet that belong to the same open platform account.
So how does the app know which small program to share? Or how does an app relate to a small program?
This depends on the code above (provided that you put the applet and the app in the same open platform account), with one line:

@"gh_*************";

The username is the applet's username, you can log on to the public platform | applet, and then in the settings---> Basic settings to view, there is a raw ID, is the username of the applet.
This way you can associate the app's sharing with the applet.
One more question: How does a shared applet open a specified page?
This depends on the other line of code:

@"pages/index/index";

You need to set up the path of the applet, which is the page where you click on the shared applet to open the page. Here is a picture of a small program development tool:

Pages refers to pages, such as the pages folder containing the detail and index and logs three pages, where:
Index: Refers to the credit card list page.
Detail: Refers to the details page that is accessed by clicking on an item in the list.
Logs: Log page
So if you want to jump to the details page, you should write "Pages/detail/detail" when you set Wxminiobject's path. This enables the click-to-Share applet to enter the specified page (if the page requires parameters you also have to share simultaneous in the past).

Wxml: equivalent to HTML
WXSS: equivalent to CSS
This is actually a small program that defines the suffix itself.

This time you share the small program scene value is 1036, and the status is true, if you have open-type in your applet is "Launchapp" button, click button you will jump back to your mobile app. If you want to return content to your app, you can set up App-parameter. Just like this little button:

<button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">打开APP</button>

In this, I think you should probably understand the applet support to open the mobile app exactly what is going on.

Summarize

Small programs do not support the opening of all mobile apps, even the same open platform account under the mobile app and applet, small programs may not be open, depending on the scene.

Prospect

Small program support Jump mobile app is a great progress, in the further completion of the small program, it should be in the app directly open the direction of the applet, and not only through the sharing open applet. In the future, we may realize that clicking a button in the mobile app will open a small program and then return to the mobile app again after the applet operation is complete. (such as payments, you can jump from the mobile app to the applet to pay, after the successful payment directly back to the mobile app)

Attached reference

1. Applet support to open the mobile app
2.LAUNCHAPP (OBJECT)

Note

Reprint Please specify source: http://www.cnblogs.com/zhanggui/p/8365169.html

Applet Support Open mobile app What the hell is going on?

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.