@@ -50,6 +50,11 @@ public void onRegisterSucceed(final Context context, final MixPushPlatform pushP
50
50
}
51
51
passThroughPlatform = pushPlatform ;
52
52
logger .log (TAG , "onRegisterSucceed " + pushPlatform .toString ());
53
+ if (handler .callPassThroughReceiver == null ) {
54
+ Exception exception = new Exception ("必须要在 register() 之前实现 setPassThroughReceiver()" );
55
+ logger .log (TAG , exception .getMessage (), exception );
56
+ return ;
57
+ }
53
58
if (Thread .currentThread () == Looper .getMainLooper ().getThread ()) {
54
59
// 在异步进程回调,避免阻塞主进程
55
60
new Thread (new Runnable () {
@@ -66,6 +71,10 @@ public void run() {
66
71
@ Override
67
72
public void onReceiveMessage (Context context , MixPushMessage message ) {
68
73
logger .log (TAG , "PassThroughReceiver.onReceiveMessage " + message .toString ());
74
+ if (handler .callPassThroughReceiver == null ) {
75
+ logger .log (TAG , "你必须设置 setPassThroughReceiver() 才能正常工作" );
76
+ return ;
77
+ }
69
78
handler .callPassThroughReceiver .onReceiveMessage (context , message );
70
79
}
71
80
}
@@ -89,6 +98,11 @@ public void onRegisterSucceed(final Context context, final MixPushPlatform mixPu
89
98
}
90
99
notificationPlatform = mixPushPlatform ;
91
100
logger .log (TAG , "onRegisterSucceed " + mixPushPlatform .toString ());
101
+ if (handler .callPushReceiver == null ) {
102
+ Exception exception = new Exception ("必须要在 register() 之前实现 setPushReceiver()" );
103
+ logger .log (TAG , exception .getMessage (), exception );
104
+ return ;
105
+ }
92
106
if (Thread .currentThread () == Looper .getMainLooper ().getThread ()) {
93
107
// 在异步进程回调,避免阻塞主进程
94
108
new Thread (new Runnable () {
@@ -105,6 +119,11 @@ public void run() {
105
119
@ Override
106
120
public void onNotificationMessageClicked (Context context , MixPushMessage message ) {
107
121
logger .log (TAG , "onNotificationMessageClicked " + message .toString ());
122
+ if (handler .callPushReceiver == null ) {
123
+ Exception exception = new Exception ("必须设置 setPushReceiver() 才能正常工作" );
124
+ logger .log (TAG , exception .getMessage (), exception );
125
+ return ;
126
+ }
108
127
if (message .getPayload () == null || message .getPayload ().length () < 5 ) {
109
128
MixPushClient .getInstance ().openApp (context );
110
129
handler .callPushReceiver .openAppCallback (context );
@@ -117,6 +136,11 @@ public void onNotificationMessageClicked(Context context, MixPushMessage message
117
136
@ Override
118
137
public void onNotificationMessageArrived (Context context , MixPushMessage message ) {
119
138
logger .log (TAG , "onNotificationMessageArrived " + message .toString ());
139
+ if (handler .callPushReceiver == null ) {
140
+ Exception exception = new Exception ("必须设置 setPushReceiver() 才能正常工作" );
141
+ logger .log (TAG , exception .getMessage (), exception );
142
+ return ;
143
+ }
120
144
handler .callPushReceiver .onNotificationMessageArrived (context , message );
121
145
}
122
146
}
0 commit comments