sequence

This is the first day of my participation in the August Text Challenge.More challenges in August

  • ‘s note | MobPush access

To tell you the truth, I want to mix a cup, the cup was broken by the cat.

PS: This is not just a simple articleMobPushAccess to summary, but also mixed with personal understanding and immature ideas. Access itself is very easy, always through the phenomenon to see the essence, to in-depth understanding of other content. The article involves the statistical data screenshots of three parties, and the link address has been provided at the end of the article. If you have any objection, please contact me to delete ~

Start by hand, record the project drip, refueling together ~

Up here or a few words, not spew fast.

What is the purpose of push? On the subway, I thought a lot:

  • Pull live, through the product features (activities) to attract users click to use, to further verify the product ideas and direction;
  • To promote user stickiness, such as today’s notification, chicken boss live ING, non-stop click into worship;
  • Major event notification and prevention, the power of science and technology, in some respects, always united front, alert to risks and strengthen vigilance;
  • .

In fact, the ultimate purpose of push, the greater personal feeling or to further retain users, no matter how to take any method.

Android is a lot more painful than iOS push. The openness of Android gradually develops and expands itself, and at the same time, the openness also derives the customization of various domestic manufacturers. Various systems emerge in an endless stream, and the blooming scene also brings a lot of compatibility problems to Android developers. IOS just needs to send it to Apple server and then do the following personal understanding, whereas Android? Here specially searched the history chart of several major domestic manufacturers:

Look, the top five manufacturers are in sight now!! Let’s look at domestic mobile phone shipments by 2021:

With the exception of Meizu’s temporary absence from the list, the rest remains strong. Huawei Hongmeng is excluded here, which is not considered in this article.

So for our native Android development, how to deal with, can achieve the best push effect? I think that’s in turn compatible with the mainstream vendors, but it also multiplies the access effort.

Better yet, where there are difficulties, there are specialist troubleshooters. For small companies, one-click access to well-formed, proven, three-party push services is the best way to go. And many domestic push service providers, we should choose which one? Continue to read ~

Push vendor comparison

I have always been in a small company. In a small company, most of the solutions are decided by the direct leaders, and some of them are chosen according to the main process preference.

Let’s make a simple comparison between aurora, Umeng, Mob and Getui from several dimensions that I pay attention to. (❌ : no, ✅ : Yes. Special cases noted separately) (as of August 10, 2021) :

The aurora Their Allies Mob A push
Support message formats Notification bar notification, custom message (transparent transmission), rich media, local notification Notification bar notification, custom message (transparent transmission), local notification Notification bar notification, custom message (transparent transmission), local notification Notification messages, custom messages (transparent transmission), and group comparison
Offline vendor channel support Huawei, Xiaomi, OPPO, Vivo, Meizu, Asus, FCM Huawei, Xiaomi, OPPO, Vivo, Meizu Huawei, Xiaomi, Meizu, OPPO, Vivo Xiaomi, Huawei, OPPO, Vivo, Meizu, Nut, Hisense, SONY, etc
Alias and tag support
Remove association startup Need to open VIP
Message to withdraw
Uninstall the statistical Advanced Edition Support
Support platform Android, iOS, Windows Phone, QuickApp Android, iOS, Flutter Android, iOS, Flutter, Unity, JavaScript, Cocos2D-X Android, iOS,

Analysis and comparison, find blind, if not, welcome pat brick ~

The figure above is a personal comparison, and some details are not considered, including the default support for server-side Web calls, for example, whether each vendor has complete support for a feature is not explained here.

There are many schemes, you can access them according to your own needs, and the MobPush integration will start now

MobPush integration

Enter from the following official website, ready to access:

  • MobPush

Select workbench after successful login:

0, Mob background to create App information

Creating an application:

  • Upload Icon
  • Fill in the App name

Then select “Access Now” :

Select MobPush here:

Add the application package name and select the vendor channel:

Access Guide:

1. Compliance treatment

Due to the further strengthening of user personal information/data control, the first priority is to ensure the compliance of App. Here is part of the arrangement according to Mob official:

  • Ensure that the App has a Privacy Policy, and the Privacy Policy will pop up when users start the App for the first time to obtain user consent;
  • Be sure to inform users of choosing MobSDK services and add reference clauses in the Privacy Policy;
  • Make sure the user agrees to the Privacy Policy, then call MobSDK to submit the privacy protocol interface.

Add MobPush dependencies to build

Buildscript {repositories {/ / configuration Mob Maven repository Maven {url "https://mvn.mob.com/android"}} dependencies {/ / integration MobPush classpath com ". The mob. The SDK: MobSDK: 2018.0319.1724 "}}Copy the code

3. Add Mob plug-in and extension in build of APP:

A separate Mob Gradle is recommended to avoid subsequent maintenance chaos.

// Call the MobTech SDK apply plugin: MobSDK {appKey" appKey" appSecret" appSecret" MobPush {// Integrate other push channels (optional) DevInfo {// HUAWEI pushes configuration information HUAWEI {appId "HUAWEI appId"} // MEIZU pushes configuration information MEIZU {appId "MEIZU appId" appKey "MEIZU appKey"} // Xiaomi pushes configuration information // FCM push channel configuration FCM {// set the default push notification display icon iconRes "@mipmap/ic_launcher"} // OPPO push configuration information OPPO {appKey" OPPO's appKey" appSecret" OPPO's appSecret"} // VIVO push configuration information VIVO {appId "Corresponding to the application appId" AppKey "Corresponding to vivo appKey"}}}}Copy the code

Then reference it in the build file under the main app:

// Apply from: 'mobsettings. gradle'Copy the code

4. Configure the privacy protocol adaptation version in gradle.properties

# set MobSDK as the privacy protocol adaptation mobsdK. spEdition=FPCopy the code

5. Add obfuscation code

This piece can be corresponding to CV according to the actual demand

# Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, # uncomment this to hide the the original source file name. # - renamesourcefileattribute SourceFile # Mob obfuscated code - keep the class com.mob.**{*; } - dontwarn com. Mob. * * # manufacturer's confusing rules - keep class. Android OS. SystemProperties - dontwarn android. The OS. SystemProperties - keep class com.huawei.**{*; } -keep class com.meizu.**{*; } -keep class com.xiaomi.**{*; } -dontwarn com.huawei.** -dontwarn com.meizu.** -dontwarn com.xiaomi.** -keepclasseswithmembernames class * { native <methods>; } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keep class com.huawei.hms.**{*; } -keep class com.meizu.cloud.**{*; } -keep class com.xiaomi.mipush.sdk.**{*; } -keep class org.apache.thrift.**{*; } -keep class com.google.** {*; } -keep class com.coloros.** {*; } -keep class com.mob.tools.* {*; } -keep class com.mob.wrappers.* {*; } -dontwarn com.mob.commons.** -dontwarn com.mob.wrappers.** -dontwarn com.huawei.hms.** -dontwarn com.meizu.cloud.** -dontwarn com.xiaomi.mipush.sdk.** -dontwarn org.apache.thrift.** -dontwarn com.google.** -dontwarn com.coloros.** -dontwarn com.vivo.push.** -keep class com.vivo.push.**{*; } -keep class com.vivo.vms.**{*; } -keep class com.mob.pushsdk.plugins.vivo.PushVivoReceiver{*; } -keep class com.meizu.cloud.pushsdk.MzPushMessageReceiver{ public *; } -keep class com.mob.pushsdk.plugins.xiaomi.PushXiaoMiRevicer {*; } -dontwarn com.xiaomi. Push.** # this is oppo obviate rule -keep public class * extends android.app com.heytap.msp.** { *; } -keep class com.mob.pushsdk.plugins.oppo.** { *; }Copy the code

6, one day,

Of course, you can also choose to enable Debug in AndroidManifest:

<! Open log - debugging - > < meta - data android: name = "com. Mob. Mobpush. DebugLevel" android: value = "4" / >Copy the code

7, Test wave, send a notice

In Mob background select send a notification test ~

The results are as follows:

Let’s Test it again, and this time we’re going to go back to the background and Test it again.

What if our app gets killed now? Can we test it again?

It can be obviously observed here that when the application is killed (simulating the time when the user is not online), the Mob background push is not delivered to the client in time. When the user opens the App again, the previous push can be received. Well, what if I open it a few days later? How to ensure the timeliness of the message? Of course, nothing is absolute.

So let’s configure huawei vendor push and try again?

8. Huawei vendor push

This is relatively simple, MobPush is also very explicit, as required to operate.

  • Huawei Push registration process

Enter the corresponding appId in MobSettings:

// Call the MobTech SDK apply plugin: MobSDK {appKey" appKey" appSecret" appSecret" MobPush {// Integrate other push channels (optional) DevInfo {// HUAWEI push configuration information HUAWEI {appId" appId"}}}}Copy the code

Then we tested the offline push test in the background of Mob:

After the above several test small case, I think everyone for access to offline vendors of the necessity of self-evident.

In fact, my personal understanding is that when the Mob’s own channel is open, that is, when the App is online, the background of Mob sends message notification through the Mob’s own channel. And if the Mob channel is closed, that is, the App is killed, I guess this is probably heartbeat packet detection? Not really, to be honest. When the device is disabled, messages are delivered through channels corresponding to different vendors. In this way, the message delivery does not depend on whether the App survives. Compared with the manufacturer (system) channel, the message will not be dried to death, thus further ensuring the message acceptance of the App.

Other manufacturers will not carry out docking test one by one here, please remember to register the relevant manufacturer account, and then configure according to MobPush.

9. Make another push to specify the user and pass the corresponding key

First get the registration ID in the App:

MobPush.getRegistrationId {
    Log.e("HLQ", "------> getRegistrationId $it")
}
Copy the code

Then get the registration ID and set the Mob background, then select custom message and set the following contents:

  • Content: This is content.
  • HlqType: 1.
  • HlqCode: 666

The corresponding message listening is as follows:

*/ Override fun onCustomMessageReceive(p0: override fun onCustomMessageReceive(p0: Context? , p1: MobPushCustomMessage? ) {log. e(TAG, "----> onCustomMessageReceive $p1")} / override fun onNotifyMessageReceive(p0: Context? , p1: MobPushNotifyMessage? ) {the e (TAG, "-- -- -- -- > onNotifyMessageReceive $p1")} inform click event / * * * * / override fun onNotifyMessageOpenedReceive (p0: Context? , p1: MobPushNotifyMessage? ) {the e (TAG, "-- -- -- -- > onNotifyMessageOpenedReceive $p1")} / label the callback operation * * * * / override fun onTagsCallback (p0: Context? , p1: Array<out String>? , p2: Int, p3: Int) {log. e(TAG, "----> onTagsCallback $p1")} Context? , p1: String? , p2: Int, p3: Int ) { Log.e(TAG, "----> onAliasCallback $p1") } })Copy the code

When you click Send in the Mob background, there is no explicit notification in the App, and in the callback interface, it outputs what we just set:

onCustomMessageReceive 
    messageId={4bp6i0t0m5xnyia9ds},
    content={This is content.},
    offlineFlag={0},
    extrasMap={{hlqCode=666, hlqType=1, 
    pushData={"hlqCode":"666","hlqType":"1"}, 
    channel=mobpush, 
    id=4bp6i0t0m5xnyia9ds}},
    timestamp={1629216359101}
Copy the code

Well, that’s the end of the code for MobPush. Most of them are official, so it’s not too full of repetitive code.

MobPush summary

From a personal point of view, each time you need to gain something, or say, expose your problems, in case the authorities are too embarrassed to adjust?

O ha ha ~ O (studying studying)

Let’s talk about it briefly from the following points.

1. Technical support

On the weekend, MobSDK couldn’t be pulled down. Ladders, network switching and hot spots were all invalid. I was sorry to bother you on the big weekend, but I solved it by group directly. Although I still handled it according to my own gradle version reduction, my attitude was very good.

On Wednesday, they gave me a special feedback at noon, saying that their technical test was normal and they provided the corresponding test Demo. Although I haven’t been able to watch it carefully due to my work, I admire my serious and responsible attitude

In a word, free stuff, and that’s not bad. The mo return ~

2. Document friendliness

From the perspective of MobPush integration, if the preparatory work has been completed (I have never met the account here, I have to deal with it by myself), online push integration is very Easy, it seems that in minutes, Mob creates the application in the background, copies the dependent build to the root, and then copies it with the official. All that remains is to license the products as necessary.

And the late manufacturer integration, relative to the point of toss, I feel more is each manufacturer toss related information, open related services. Huawei, for example, is a mess and has to download files. In fact, the Mob background configuration is relatively simple, that key and so on, the same for local projects.

Here is a brief summary of my personal feelings:

Concise document. apply{Easy access Not easy to obtain detailed logs, for example, is huawei integration successful? For some failure cases, no more resolution examples are provided}Copy the code

On the second point, here I take huawei offline vendor push as an example:

  • MobPush background configuration
  • Huawei Push registration process

The above two links are officially provided by MobPush, but how can I know that MY huawei channel access is successful when I access again? Please forgive me for not finding the relevant instructions. Here’s a random positive example:

In fact, in my opinion, the easiest way to document friendliness is to give developers the fastest access to the required features. And can access to the content, the official documentation, such as how to calculate the success of failure? How was I supposed to know this in the first place? Rather than requiring the individual to actually send the notification test in order to reach a conclusion. (Mob, don’t hit me!)

About this document update, in fact, will lead to misunderstandings, a few simple examples:

  • The official MobSDK dependency address, the integration document is HTTPS, download SDK is written HTTP. Although the follow-up consultation official, official support, but still come up to give people the feeling of misunderstanding.
  • At present, according to the personal test, the corresponding manufacturer is automatically configured according to the configured manufacturer channel. I have a question: suppose MobPush fails to actively update the manufacturer or the developer wants to replace it by himself one day? Curious about this one.

Or hope that the official can seriously unified treatment, after all, a negligence will cause integration of helpless.

People always want more, O(∩_∩) haha ~

Dig a little deeper into the SDK

So the whole thing is integrated, and I don’t know if you noticed that we never called init at all, but where did it get initialized?

Could it be ContentProvider? The impression is that this object is called between Application attachBaseContext and onCreate.

Blind guessing is better than going straight to the SDK

Digging into the SDK, WE found that Mob currently provides two ways:

  • Init MobApplication: onCreate ()
  • Init ContentProvider: onCreate ()

Decompile the generated Apk, and Mob will replace application name with MobApplication, as shown below:

<application 
    android:name="com.mob.MobApplication" >
Copy the code

I’m not just smiling here, but what if I inherit MobApplication from Application? Will you replace it for me?

class BaseApplication : MobApplication() {

    override fun onCreate() {
        super.onCreate()
    }

}
Copy the code

Decompile APK again to see:

<application 
    android:name="com.hlq.mob.BaseApplication" >
Copy the code

Also, inherit MobApplication and replace it with a hammer?

Not to mention, this dynamic substitution is interesting. For example, my integration process does not add permissions. When are those permissions injected?

Strangely enough, AndroidManifest also sees the ContentProvider mentioned above:

<provider
    android:name="com.mob.MobProvider"
    android:exported="false"
    android:multiprocess="true"
    android:authorities="com.pwccn.klcore.com.mob.MobProvider" />
Copy the code

What kind of logic is that? I’m a little confused. Take a little notebook and write it down. We’ll talk about it later.

A comparison 6 operation was also found during:

  • When I do not configure channels in the profile, the SDK automatically pulls Mob dependencies.
  • If only Huawei exists in the configuration file, the SDK automatically extracts huawei dependencies.

This operation is very magical ah, there is no elder brother guidance point a lower that ~

All kinds of confusion, look at the loss, next time have a chance to say ~

Error

  • If the current AS version is the latest and Gradle version is 7.0, MobSDK fails to be pulled, simply lower gradle version. Of course, the official Demo of Gradle 7.0 was provided in the end, but I didn’t study it in detail because I was too lazy.

  • If vendor push fails, check whether related package names are configured according to official requirements. I just screwed myself up. Do not throw a Demo to the official, let the official help deal with next. O ha ha ~ O (studying studying)

THK

  • Q2 2021 China Mobile Phone Market Shipments/Share ranking: Top five Vendors detailed data report
  • Research report on Mobile Operating System industry in China in 2021
  • Friendship push, aurora push, MobPush, push, push unified push alliance