preface

Imagine a scenario where I invite someone to download and sign up for an app so he can get a reward and I can get a reward. How do I match the inviter with the invitee? Then you must say, this is not simple, invitation code ah, each user has their own unique invitation code, the invitee party download and register to fill in the corresponding invitation code, isn't it good? However... Is it no trouble?? If brother my app with invitation code, that much more convenient ah!! The recommended process for downloading APP is as follows:Copy the code

Chouchou’s recommended App download process



The browser



Android opens the mobile app through the browser






OpenInstall

integration

  • Integration of the jar
Integrated jars

  • Configuration AndroidMainfest

    Access configuration
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>Copy the code

    App_key configuration

    <! - openInstall appKey -- -- >
          <meta-data
              android:name="com.openinstall.APP_KEY"
              android:value="ipriom"/>
          <! End of openInstall appKey -->Copy the code

Configure the Activity that gets the parameters

  <! -- Home page -->
        <activity
            android:name=".MainActivity"
            android:windowSoftInputMode="adjustPan|stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="op4nd2v6"/>
            </intent-filter>
        </activity>Copy the code

Matters needing attention

Matters needing attention


  <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>Copy the code
 <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="op4nd2v6"/>
            </intent-filter>Copy the code
  • Configure the Application

Configure in onCreate()

 if (isMainProcess()) {
            OpenInstall.init(this);
            OpenInstall.setDebug(true);
        }Copy the code
 /** * Check if it is the main process **@return* /
    public boolean isMainProcess(a) {
        int pid = android.os.Process.myPid();
        ActivityManager activityManager = (ActivityManager) getSystemService
                (Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningAppProcessInfo appProcess : activityManager
                .getRunningAppProcesses()) {
            if (appProcess.pid == pid) {
                returngetApplicationInfo().packageName.equals(appProcess.processName); }}return false;
    }Copy the code
  • Configuring obfuscation files
    ** keep public class com.fm.openinstall.* {*; }Copy the code
  • Let’s look at how to get data from MainActivity:
  1. Set the parameter callback to wake up the App in onCreate () :
    /** * Set the callback to get parameters when getting wake up app */
     private void getWakeUpInfo(a) {
         OpenInstall.getWakeUp(getIntent(), this);
     }Copy the code
  2. Gets the argument passed to wake up the App

    @Override
     public void onWakeUpFinish(AppData appData, Error error) {
         XLog.e(error == null ? appData.toString() : error.toString());
     }Copy the code
  3. Configuration onNewIntent

     @Override
     protected void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
         // Call it here, otherwise the App will not be intercepted when running in the background
         OpenInstall.getWakeUp(intent, this);
     }Copy the code

    Above words, in fact, we can achieve their own, through the above provided article, this step we can do it by ourselves. But there’s another method that bloggers can’t figure out how to do:

    /** * Gets the parameter information passed from the Web side during installation */
     private void getInfo(a) {
         OpenInstall.getInstall(new AppInstallListener() {
             @Override
             public void onInstallFinish(AppData appData, Error error) {
                 if (error == null) {
                     if (appData == null) {
                         return;
                     }
                     if(! TextUtils.isEmpty(appData.getData())) { Toast.makeText(MainActivity.this."Wake up the app from the web"+ appData.toString(), Toast.LENGTH_SHORT).show(); }}else {
                     XLog.e("error--------------"+ error.toString()); }}}); }Copy the code

Here we explain the difference between the two methods: getInfo onWakeUpFinish: the top of the getInfo onWakeUpFinish method is the first time that the app has been installed, and the bottom is the app has been installed.

Isn’t there already a bit of confusion here?! Take a look at the test document that dude wrote earlier:

test

  • The url address:
    https://app-ipriom.openinstall.io/js-test?
    testKey=11111111&testKey2=3333333333333333333333Copy the code

TestKey =11111111&testKey2=33333333333333333333

  • Enter the following address in your browser:

    Enter the address

  • Press enter to run

Running interface

  • If you’re running this app for the first time (i.e., you don’t have it installed on your phone), you’ll get to the download page:
First run as download

  • After the installation, click Run and here we can get the parameters passed in
Gets the passed argument

  • It can be modified at this point? testKey=11111111&testKey2=3333333333333333333333Parameters of the column

    Table, app can also obtain the modified parameter list. For example, change it to? testKey=keyValueLater, pull up

    The page is:
A page that runs twice

Here is not already can see the clue!

  • One way to do this is to get the parameters that are passed at installation time. This is just a one-time thing
  • The other method is to get the parameters passed on wake up, which can be used countless times and the parameters can change at any time.

Here, in fact, has met our needs!

process

test

We are more concerned about compatibility issues, here the blogger also took a little time to test: test:

  • UC browser, QQ browser and other mainstream browsers, can be pulled up
  • On the premise of pulling up, whether the parameters can be obtained and whether the parameters are correct. On the premise of pulling up the APP through the web page, the following conditions can be met:
  1. The phone has an app installed
  2. The app has been opened at least once
  3. Has nothing to do with whether the network is switched over.
  • Samsung: Representative model: Samsung S8 + Native browser test passed QQ browser test passed 360 browser test passed UC browser test
  • Mi: Representative model: Mi 6 Native browser test through 360 browser test through UC browser test through QQ browser test
  • Huawei: Representative model: Huawei P9 (with high configuration and full Netcom) Native browser Test Passed QQ browser test passed 360 browser test Passed UC browser test
  • Note3 native browser test through QQ browser test through 360 browser test through UC browser test
  • VIVO: Representative model: VIVOX9I Native browser test passed QQ browser test passed 360 browser test passed UC browser test
  • HTC representative model: HTCm9w Native browser test QQ browser test 360 browser test UC browser test passed
  • OPPO model: OPPOR9S Native browser test Passed QQ browser test passed 360 browser test passed UC browser test

Test summary:

1 URL I can casually assemble 2.UC, QQ, native can pull up application 3. 4. Reinforcement confusion does not affect this function

Conclusion:

2. Every time we update the version, we need to submit it to the background hosting of openInstall (to ensure the stability of subsequent updates). We can also directly host it to the platform such as App Treasure, so that the browser under Goofactory will provide support (the built-in browser of wechat).