15
15
*/
16
16
package com .huawei .push .examples ;
17
17
18
- import com .alibaba .fastjson .JSONObject ;
18
+ import com .alibaba .fastjson .JSON ;
19
19
import com .huawei .push .android .AndroidNotification ;
20
- import com .huawei .push .android .BadgeNotification ;
21
20
import com .huawei .push .android .ClickAction ;
22
- import com .huawei .push .android .Color ;
23
- import com .huawei .push .android .LightSettings ;
24
21
import com .huawei .push .exception .HuaweiMesssagingException ;
25
22
import com .huawei .push .message .AndroidConfig ;
26
23
import com .huawei .push .message .Message ;
27
24
import com .huawei .push .message .Notification ;
28
25
import com .huawei .push .messaging .HuaweiApp ;
29
26
import com .huawei .push .messaging .HuaweiMessaging ;
30
- import com .huawei .push .model .Urgency ;
31
- import com .huawei .push .model .Importance ;
32
- import com .huawei .push .model .Visibility ;
33
27
import com .huawei .push .reponse .SendResponse ;
34
28
import com .huawei .push .util .InitAppUtils ;
35
29
@@ -42,7 +36,7 @@ public void sendTestMessage() throws HuaweiMesssagingException {
42
36
.setBody ("sample message body" )
43
37
.build ();
44
38
45
- JSONObject multiLangKey = new JSONObject ();
39
+ /* JSONObject multiLangKey = new JSONObject();
46
40
JSONObject titleKey = new JSONObject();
47
41
titleKey.put("en","好友请求");
48
42
JSONObject bodyKey = new JSONObject();
@@ -53,46 +47,56 @@ public void sendTestMessage() throws HuaweiMesssagingException {
53
47
LightSettings lightSettings = LightSettings.builder().setColor(Color.builder().setAlpha(0f).setRed(0f).setBlue(1f).setGreen(1f).build())
54
48
.setLightOnDuration("3.5")
55
49
.setLightOffDuration("5S")
56
- .build ();
50
+ .build();*/
57
51
58
- AndroidNotification androidNotification = AndroidNotification .builder ().setIcon ("/raw/ic_launcher2" )
59
- .setColor ("#AACCDD" )
60
- .setSound ("/raw/shake" )
61
- .setDefaultSound (true )
62
- .setTag ("tagBoom" )
52
+ AndroidNotification androidNotification = AndroidNotification .builder ()
53
+ .setTitle ("你有新的消息" )
54
+ .setBody ("你在干啥?" )
55
+ //.setIcon("/raw/ic_launcher2")
56
+ //.setColor("#AACCDD")
57
+ //.setSound("/raw/shake")
58
+ //.setDefaultSound(true)
59
+ //.setTag("tagBoom")
63
60
.setClickAction (ClickAction .builder ().setType (2 ).setUrl ("https://www.huawei.com" ).build ())
64
- .setBodyLocKey ("key2" )
65
- .addBodyLocArgs ("boy" ).addBodyLocArgs ("dog" )
66
- .setTitleLocKey ("key1" )
67
- .addTitleLocArgs ("Girl" ).addTitleLocArgs ("Cat" )
68
- .setChannelId ("Your Channel ID" )
69
- .setNotifySummary ("some summary" )
70
- .setMultiLangkey (multiLangKey )
71
- .setStyle (1 )
72
- .setBigTitle ("Big Boom Title" )
73
- .setBigBody ("Big Boom Body" )
74
- .setAutoClear (86400000 )
75
- .setNotifyId (486 )
76
- .setGroup ("Group1" )
77
- .setImportance (Importance .LOW .getValue ())
78
- .setLightSettings (lightSettings )
79
- .setBadge (BadgeNotification .builder ().setAddNum (1 ).setBadgeClass ("Classic" ).build ())
80
- .setVisibility (Visibility .PUBLIC .getValue ())
81
- .setForegroundShow (true )
61
+ // .setBodyLocKey("key2")
62
+ // .addBodyLocArgs("boy").addBodyLocArgs("dog")
63
+ // .setTitleLocKey("key1")
64
+ // .addTitleLocArgs("Girl").addTitleLocArgs("Cat")
65
+ // .setChannelId("Your Channel ID")
66
+ // .setNotifySummary("some summary")
67
+ //// .setMultiLangkey(multiLangKey)
68
+ // .setStyle(1)
69
+ // .setBigTitle("Big Boom Title")
70
+ // .setBigBody("Big Boom Body")
71
+ // .setAutoClear(86400000)
72
+ // .setNotifyId(486)
73
+ // .setGroup("Group1")
74
+ // .setImportance(Importance.LOW.getValue())
75
+ //// .setLightSettings(lightSettings)
76
+ // .setBadge(BadgeNotification.builder().setAddNum(1).setBadgeClass("Classic").build())
77
+ // .setVisibility(Visibility.PUBLIC.getValue())
78
+ // .setForegroundShow(true)
82
79
.build ();
83
80
84
- AndroidConfig androidConfig = AndroidConfig .builder ().setCollapseKey (-1 )
85
- .setUrgency (Urgency .HIGH .getValue ())
86
- .setTtl ("10000s" )
87
- .setBiTag ("the_sample_bi_tag_for_receipt_service" )
81
+ AndroidConfig androidConfig = AndroidConfig .builder ()
82
+ //.setCollapseKey(-1)
83
+ //.setUrgency(Urgency.NORMAL.getValue())
84
+ //.setTtl("10000s")
85
+ //.setBiTag("the_sample_bi_tag_for_receipt_service")
88
86
.setNotification (androidNotification )
89
87
.build ();
90
88
91
- Message message = Message .builder ().setNotification (notification )
89
+ Message message = Message .builder ()
90
+ //.setNotification(notification)
92
91
.setAndroidConfig (androidConfig )
93
- .addToken ("AND8rUp4etqJvbakK7qQoCVgFHnROXzH8o7B8fTl9rMP5VRFN83zU3Nvmabm3xw7e3gZjyBbp_wfO1jP-UyDQcZN_CtjBpoa7nx1WaVFe_3mqXMJ6nXJNUZcDyO_-k3sSw " )
92
+ .addToken ("IQAAAACy0LgAAADBbzjXeF4Y-BTmHuEkn6fwOdK0a-FP1wUHByFpI-gHHg7fcxNc1eEDG0jNWNtS_vQZ91IqBMJssJoYpCuwVXtyeG8J2xYqLHwu5Q " )
94
93
.build ();
95
94
96
- SendResponse response = huaweiMessaging .sendMessage (message , true );
95
+ SendResponse response = huaweiMessaging .sendMessage (message , false );
96
+ System .out .println (JSON .toJSONString (response ));
97
+ }
98
+
99
+ public static void main (String [] args ) throws HuaweiMesssagingException {
100
+ new SendTestMessage ().sendTestMessage ();
97
101
}
98
102
}
0 commit comments