Android, ios, Android app push message notification, Java background push app notification tutorial to mobile phone

1. Business introduction

1.1 Product Introduction

GeTui is a commercial-grade mobile application message push cloud service provider. The client SDK supports Android and iOS platforms. After integrating the SDK, developers can send push messages through GeTui's powerful web end and rich API open interfaces. Statistically analyze push effects. It can effectively improve App activity and increase user retention rate.

1.2 Definition of terms

Insert image description here
Insert image description here

1.3 Message push process

Insert image description here

2. Application creation

If you don’t have a GeTui account yet, you can complete account registration on the GeTui official website.
If you don't have a push application yet, you can refer to [Add Service] in the Developer Center Instructions to complete the creation of a message push application.

3. Client SDK integration

If you need to use the Personal Push message push service on your mobile device, you must first complete the client SDK integration.

3.1 Android

Android GeTui main package: GeTui provides a safe and stable push SDK for Android applications. After integrating the main package, only "online push" can be used.
Android multi-vendor package: Getui cooperates with mainstream Android manufacturers to integrate the manufacturer push SDK. After configuring multi-vendor parameters in the background of the Getui Developer Center and integrating the multi-vendor package, "offline push" can be used at the same time, which can improve the performance of Android manufacturers. Message arrival rate on the device.
Completion of manufacturer news reports: Since no impressions are returned through personal push, Huawei, Honor, OPPO, and vivo do not have complete offline click report reports. In order to facilitate you to see more complete push data statistics in the backend of personal push, we recommend that you Report completion on the client side.

3.2 iOS

iOS GeTui main package: GeTui provides a safe and stable push SDK for iOS applications. After integrating the main package, only "online push" can be used.
iOS push certificate: The push notification function supported by iOS. After exporting the certificate from Apple's official developer website and configuring it in the background of the Personal Push Developer Center, you can use "offline push" at the same time, which can improve the message arrival rate on iOS devices.

4. Server push

Developers can send messages from the page by calling the server RestAPI V2 or logging in to the GeTui Developer Center. (If you want to push to a single cid user, cid must be obtained from the client first)

4.1 Server message delivery process (must read)

When CID is online (that is, the app is open and running in the foreground):

The message is sent to the client through a push channel.

Specifically, in the server RestAPI-V2 code, the notification (notification) or transmission (transparent transmission) content in push_message is passed to the client.

Note: The iOS system does not display push online notification messages, so when the push user is iOS, only transmission can be used in push_message. The iOS client will display the notification bar by itself when receiving online.

When the CID is offline (that is, the app is in the background, the screen is locked, and the process is closed):

If the corresponding manufacturer's offline function is enabled, the message will be requested through the push side to the corresponding manufacturer's server.

Specifically in the server-side RestAPI-V2 code, that is, the notification content in push_channel is passed to the manufacturer, and the actual message is sent to the client via the manufacturer's server; for those that do not have the corresponding manufacturer function turned on, the message will be stored in a push offline library , wait for the CID to be online, and then send it to the client through the push channel.

Note: If the server push_channel does not pass a value, offline messages cannot be received.

4.2 Developer Center backend

Log in to the GeTui Developer Center and enter the GeTui message push dos page. You can [Create Push] in the following 2 ways.

https://dev.getui.com/
After the registration is completed, enter the message push service:
Insert image description here
Insert image description here
create a new test app. After the construction is completed, you can get the app information in My -> Application Management:
Insert image description here
Insert image description here
the information here will be on the server later. It will be used when calling. Interested friends can download the demo of the server sdk, which is of great research value.

4.3 Push code

I won’t add other details and client information. There are good explanations and explanations in the GeTui official website documentation.
https://docs.getui.com/getui/server/rest_v2/service_sdk/

Add dependencies:

<dependency>
    <groupId>com.getui.push</groupId>
     <artifactId>restful-sdk</artifactId>
     <version>1.0.0.1</version>
 </dependency>
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
        //填写应用配置
        apiConfiguration.setAppId("-----");
        apiConfiguration.setAppKey("-----");
        apiConfiguration.setMasterSecret("-----");
        // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
        apiConfiguration.setDomain("https://restapi.getui.com/v2/");
        // 实例化ApiHelper对象,用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
        // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
        PushApi pushApi = apiHelper.creatApi(PushApi.class);

        //推送
        //根据cid进行单推
        PushDTO<Audience> pushDTO = new PushDTO<Audience>();
        // 设置推送参数
        pushDTO.setRequestId(System.currentTimeMillis() + "");
        PushMessage pushMessage = new PushMessage();
        pushDTO.setPushMessage(pushMessage);
        GTNotification notification = new GTNotification();
        pushMessage.setNotification(notification);
        notification.setTitle("测试标题" + new Date());
        notification.setBody("哈哈哈");
        notification.setClickType("url");
        notification.setUrl("https://www.getui.com");
        // 设置接收人信息
        Audience audience = new Audience();
        pushDTO.setAudience(audience);
        audience.addCid("77b5b288038f1a418d071-----------");

        // 进行cid单推
        ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
        if (apiResult.isSuccess()) {
    
    
            // success
            System.out.println(apiResult.getData());
        } else {
    
    
            // failed
            System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
        }

Test Results:
Insert image description here

5. Parameter description

https://docs.getui.com/getui/server/rest_v2/common_args/

Insert image description here
Insert image description here
Insert image description here
Wait, you can download the official sdk project to view

Guess you like

Origin blog.csdn.net/wang121213145/article/details/128953874