Android integration openinstall

The role of openinstall:

Step 1: Log in to the openinstall official website and register if you don’t have an account

Step 2: Add an app if you don’t have one (select the premium version)

Step 3: Download and import the sdk (actually just a jar)

Put the downloaded OpenInstall_v2.3.0.jar into the libs folder, and then add it under [build.gradle]

dependencies {
     implementation  files('libs/OpenInstall_v2.3.0.jar')
}

Step 4: Add permission declaration in AndroidManifest.xml

<uses-permission android: />
<uses-permission android: />

Step 5: Set AppKey in the application tag of AndroidManifest.xml

<meta-data
    android:
    android:value="******"/>

Step 6: Add initialization code to the application

@Override
public void onCreate() {
    super.onCreate();
    if (isMainProcess()) {
        openInstall();
    }
}

//Determine whether it is the main process 
public boolean isMainProcess () {
    int pid = android.os.Process.myPid();
    ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) {
        if (appProcess.pid == pid) {
            return getApplicationInfo().packageName.equals(appProcess.processName);
        }
    }
    return  false ;
}

Step 7: Specify your application in AndroidManifest.xml

<application
    android:
/>

Step 8: Implement fast download

If you only need the fast download function, no other functions (installation with parameters, channel statistics, one-click pull-up) are required, and the initialization can be completed.

Step 9: Install with parameters, add the following code in the application

private  void  openInstall ()  {
     //Initialize 
    OpenInstall.init( this ); 
     //Install with parameters 
    OpenInstall.getInstall( new AppInstallAdapter() {
         @Override 
        public  void  onInstall (AppData appData)  {
            Log.d(TAG, "appData=" + appData);
             //Get channel data
            channelCode = appData.getChannel();
            //Get custom data 
            try {
                duanzishou = new JSONObject(appData.getData()).optString("duanzishou");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}

Step 10: Test the installation with parameters (the application scenario is to invite others to download and install without filling in the invitation code, etc. The information of the invitation code is in the custom parameters of the link, such as the download link https://app-* ***.openinstall.io/channel-landing?phoneNumber=1 3*****, after the invited user installs, openinstall obtains custom parameters, and then can register through the interface Upload this parameter value to the background server)

  1. On the openinstall official website, click Android Integration, click APK Package, and click Upload APK File

  2. In the list below this interface, click Test

  3. In the key in the pop-up box, write the custom parameter name to be obtained written in the application, and click Generate Test Connection

  4. Click the link to jump to the download apk interface, click Use Now, download the apk, and install it on the phone

5. Delete the previous package, install the downloaded package on the phone, open it, and see the result (channel is not set, the custom parameters are obtained)

Step 11: Add code to the activity that needs to be pulled up with one click

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    OpenInstall.getWakeUp(getIntent(), wakeUpAdapter);
}
@Override 
protected  void  onNewIntent (Intent intent)  {
     super .onNewIntent(intent);
     // To be called here, otherwise the App will not be able to intercept when it is running in the background
    OpenInstall.getWakeUp(intent, wakeUpAdapter);
}
AppWakeUpAdapter wakeUpAdapter = new AppWakeUpAdapter() {
     @Override 
    public  void  onWakeUp (AppData appData)  {
         //Get channel data
        String channelCode = appData.getChannel();
        //get binding data
        String bindData = appData.getData();
        Log.d("appData", "getWakeUp : wakeupData = " + appData.toString());
    }
};
@Override
protected void onDestroy() {
    super.onDestroy();
    wakeUpAdapter = null;
}

Step 12: Add an intent-filter (usually MainActivity) to the activity tag of the wake-up page in AndroidManifest.xml, and configure the scheme for pulling up in the browser

<intent-filter>
    <action android:/>
    <category android:/>
    <category android:/>
    <data android:scheme="******"/>
</intent-filter>

Step 13: Upload apk, set custom parameters and values, generate link and QR code, scan the QR code, and the mobile phone will jump to the link interface, click to use it immediately, and it will automatically jump to the program

Step 14: View the value of the acquired parameter pulled up with one key

Step 15: Configure channel parameters, click Channel Management, add a channel, and then click the channel link to display https://app-*.openinstall.io/channel-landing?channelCode=00000111 (there is channel information channelCode here , but this link has no custom parameters, there is a custom link with parameters but no channel information, if I want both, (this connection is generated in the background, given in the background, I will splicing it here) https: //app-***.openinstall.io/js-test/android/1047412755738029502?duanzishou=%E5%A4%A7%E5%BC%A0%E4%BC%9F&channelCode=00000111 )

Step 16: Generate a QR code from the spliced ​​link on the forage QR code website (https://cli.im/url)

Step 17: Scan the QR code, download the apk, install, open, and test whether the parameters are obtained

Step 18: Statistics of registrations (see business needs)

//Call OpenInstall.reportRegister() after user registration is successful;

Step 19: View application statistics and channel reports

Leave a Comment

Your email address will not be published. Required fields are marked *