A push of Android push services

A:

Gitui is a commercial-grade cloud service provider for mobile application messaging

1. Message type

Push a message to support notification and through two forms. At the same time, it supports large image, large text and other rich media display, and supports subsequent operations such as launching the application, opening the third-party link, opening the specific page within the application and other follow-up operations.

Notice:

After the notification title and content are specified, it will be automatically processed by the push SDK and displayed in the notification bar of the system in the form of notification bar message. At the same time, the user will be reminded by ringing or vibrating (the ringing and vibration are affected by the setting state of the mobile phone system).

Passthrough:

That is, custom message, message frame can be defined by the customer, such as plain text, JSON string, etc. A push through message only transmits data and does not do any processing. After receiving the through message, the client needs to do subsequent action processing by itself, such as notification bar display, pop-up box, etc.

2. Push the target

Push support to passTag (Tag),Alias (Alias),CID(Clientid, a unique identifier for each push SDK),The user groupFour ways to manage target user Settings that developers can use flexibly based on their business needs.



We need to maintain this ClientID

Two: a push official website registration APP



Get the AppID, AppKey, etc



Refer to the development documentation for detailshttps://docs.getui.com/getui/…

Three: a push integration

Step 1: Maven integration (used to be lib libgetuiext2.so integration)The latest so of SDK is libgetuiext3.so. Since only Maven mode integration is supported, please delete all libgetuiext2.so and libgetuiext.so in the original JNilibs directory when upgrading the old version.)

In the AllProjects. Repositories block of the project root directory build.gradle, Add a push maven repository address maven {url “https://mvn.getui.com/nexus/content/repositories/releases/”}


allprojects {
    repositories {
        google()
        jcenter()
        maven { url "http://mvn.gt.igexin.com/nexus/content/repositories/releases/" }
    }
}

Step 2: Configure dependencies

Android {defaultConfig{// I'm using version 2.14.1.0, starting with version 3.1.2.0, APPID placeholders for switch from GETUI_APP_ID GETUI_APPID / / follow-up and all the products are APPID unified configuration for GETUI_APPID placeholder manifestPlaceholders = [GETUI_APP_ID: "o3b2zj****************", GETUI_APP_KEY : "WefOi****************", GETUI_APP_SECRET : "Iodl * * * * * * * * * * * * * * * *", GS_APPID: "o3b2 * * * * * * * * * * * * * * * *", / / / / channel for pure figures were not beyond the scope of int said. GT_INSTALL_CHANNEL: "Atest"] NDK {// Select the.so library for the corresponding CPU type to add. abiFilters 'arm64-v8a','armeabi', 'armeabi-v7a', 'x86_64' dependencies' x86 '}}} {/ / push API rootProject. Ext. Dependencies [" getui "] / / equivalent to the API 'com. Getui: GTSDK: 2.14.1.0' / / a push statistics API rootProject. Ext. Dependencies "getuigs"] / / API 'com. Getui: GSSDK: 2.3.0.1'}

Step 3: Add Android permissions to the AndroidManifest.xml file

<! - network connections - > < USES - permission android: name = "android. Permission. INTERNET" / > <! - check the network status, the SDK reconnection mechanism need to use - > < USES - permission android: name = ". Android. Permission ACCESS_NETWORK_STATE "/ > <! (b) Get the status parameter of the phone and use it as a necessary parameter to generate the unique identifier of a tweet. (b) - check the wifi connection state - > < USES - permission android: name = "android. Permission. ACCESS_WIFI_STATE" / > <! - since the launch of boot permissions, improve the SDK active, guarantee touch - > < USES - permission android: name = "android. Permission. RECEIVE_BOOT_COMPLETED" / > <! --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <! Shaking -- -- -- > < USES - permission android: name = "android. Permission. VIBRATE" / > <! -- Get task information in order to prevent the SDK from waking up frequently --> <uses-permission Android :name=" Android.permission. Get_tasks "/>

And compatible with Android 9.0 in application node add Android: usesCleartextTraffic = “true” step 4: initialize a service Add in the Application

public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); PushManager.getInstance().initialize(this); PushManager.getInstance().initialize(this); Boolean isDebug = apputils.isAppDebug (); String channel = InitData.getInstance().getChannel(); initGS(isDebug,channel); } private void initGS(Boolean IsDebug, String Channel) {// Configure a String channel. From the start the application to close the application / / 2. From the start the application to the application to the background, and runs in the background of time more than 30 s GsConfig. SetSessionTimoutMillis (20 * 60 * 1000); // Enable developer mode: gsconfig.setDebugenable (isDebug); GsConfig.setInstallChannel(channel); // The SDK initializes GSManager.getInstance ().init(mApplication); }}

To simplify the integration step, just call the new PushManager.getInstance().Initialize (Context Context) interface to complete the SDK initialization. The Push SDK will automatically look for the corresponding PushService and GtintentService interface changes after version 2.9.5.0. Integration initialization is now easier

  • PushManager.getInstance().Initialize (Context Context) is a new interface that is recommended for initialization.
  • New PushManager.getInstance().setDebugLogger(Context Context, IUserLoggerInterface LoggerInterface) interface for debugging log output.
  • Call a pushed the initialization code, com. Igexin. SDK. PushManager. GetInstance (). The initialize (Context Context) initialization for the SDK. We recommend that developers initialize a push SDK in the Application.onCreate() and main Activity.onCreate() methods. Calling the SDK initialization multiple times doesn’t matter. In order to ensure the stability of SDK services, it is recommended to guide users to authorize relevant privacy rights.

Step 5: Customize the Receive and Push service

public class MessageReceiveIntentService extends GTIntentService { private static boolean isNotify; @Override 00 public void onReceiveServicePid(Context context, int i) { Log.d("aa", i + ""); } public void onReceiveClientid (Context Context, String Clientid) {logutils.e (Tag, String Clientid);} public void onReceiveClientid (Context Context, String Clientid) {logutils.e (Tag, String Clientid); "onReceiveClientId -> " + "clientId = " + clientId); reportCid(clientId); } private void reportCid(String cid) { if (InitData.getInstance().getUserDbBean() ! = null) { CommonHttpUtils.reportCid(cid); }} public void OnReceiveMessageData (Context Context,);} public void OnReceiveMessageData (Context Context); GTTransmitMessage GTTransmitMessage) {/ / passthrough message processing String message = new String (GTTransmitMessage. GetPayload ()). The trim (); LogUtils.d("onReceiveMessageData,getPayload:", message); LogUtils.d("onReceiveMessageData,getMessageId:", gtTransmitMessage.getMessageId()); LogUtils.d("onReceiveMessageData,getPayloadId:", gtTransmitMessage.getPayloadId()); LogUtils.d("onReceiveMessageData,getTaskId:", gtTransmitMessage.getTaskId()); } public void OnReceiveOnLineState (Context Context,);} public void OnReceiveOnLineState (Context Context,); Boolean b) {} /** * Receipt 00 */ @Override public void OnReceiveCommandResult (Context Context, GTCmdMessage gtCmdMessage) { LogUtils.d("onReceiveCommandResult,getAction:", String.valueOf(gtCmdMessage.getAction())); } /** * notification arrives, Only a push notification channel issued by this method will callback 00 * / @ Override public void onNotificationMessageArrived (Context Context, GTNotificationMessage gtNotificationMessage) { LogUtils.d("onNotificationMessageArrived,getContent:", gtNotificationMessage.getContent()); LogUtils.d( "onNotificationMessageArrived,getMessageId:", gtNotificationMessage.getMessageId()); LogUtils.d("onNotificationMessageArrived,getTaskId:", gtNotificationMessage.getTaskId()); LogUtils.d("onNotificationMessageArrived,getTitle:", gtNotificationMessage.getTitle()); } /** * Notice click, Only a push notification channel issued by this method will callback 00 * / @ Override public void onNotificationMessageClicked (Context Context, GTNotificationMessage gtNotificationMessage) { LogUtils.d("onNotificationMessageClicked,getContent:", gtNotificationMessage.getContent()); LogUtils.d( "onNotificationMessageClicked,getMessageId:", gtNotificationMessage.getMessageId()); LogUtils.d("onNotificationMessageClicked,getTaskId:", gtNotificationMessage.getTaskId()); LogUtils.d("onNotificationMessageClicked,getTitle:", gtNotificationMessage.getTitle()); }}

Step 6: Configure the service

<! > <service > : > <service > : > <service > : > <service > : > <service > : > <service > : > <service android:name=".pushservice.MessageReceiveIntentService" android:permission="android.permission.BIND_JOB_SERVICE" />

Step 7: Configure the push service

Public class MessageCustomPushService extends PushService {} // Service <service > android:name=".pushservice.MessageCustomPushService" android:exported="true" android:label="PushService" android:permission="android.permission.BIND_JOB_SERVICE" android:process=":pushservice" />

Note: use the maven integration, android: process attribute must be a pushservice step 8: set the notification icon You may refer to specific push integrated document https://docs.getui.com/getui/… Tag[] tags=new Tag[]{}; PushManager.getInstance().setTag(Context context,Tag[] tags,String s); Label interface class, used to label the user (such as can be used for precise push) four: the use of push

At the end: to have the most simple life and the most distant dream, even if tomorrow cold, mountain high water far, road far horse dead