24
24
25
25
import android .app .Application ;
26
26
import android .content .Context ;
27
+ import android .os .Bundle ;
27
28
import android .support .multidex .MultiDex ;
28
29
import android .text .TextUtils ;
29
30
import android .util .Log ;
45
46
import javax .net .ssl .X509TrustManager ;
46
47
47
48
import de .duenndns .ssl .MemorizingTrustManager ;
49
+ import eu .inloop .easygcm .EasyGcm ;
50
+ import eu .inloop .easygcm .GcmListener ;
48
51
import nl .hnogames .domoticz .R ;
52
+ import nl .hnogames .domoticz .Utils .NotificationUtil ;
53
+ import nl .hnogames .domoticz .Utils .SharedPrefUtil ;
49
54
50
55
51
- public class AppController extends Application {
56
+ public class AppController extends Application implements GcmListener {
52
57
53
58
public static final String TAG = AppController .class .getSimpleName ();
54
59
private static AppController mInstance ;
@@ -66,6 +71,7 @@ public void onCreate() {
66
71
67
72
//for debugging & receiving crash reports
68
73
Mint .initAndStartSession (this , "a61b1e35" );
74
+ EasyGcm .init (this );
69
75
70
76
mInstance = this ;
71
77
}
@@ -134,4 +140,18 @@ synchronized public Tracker getDefaultTracker() {
134
140
}
135
141
return mTracker ;
136
142
}
143
+
144
+ @ Override
145
+ public void onMessage (String s , Bundle bundle ) {
146
+ if (bundle .containsKey ("message" ))
147
+ {
148
+ String message = bundle .getString ("message" );
149
+ NotificationUtil .sendSimpleNotification ("Domoticz" , message , this );
150
+ }
151
+ }
152
+
153
+ @ Override
154
+ public void sendRegistrationIdToBackend (String s ) {
155
+ new SharedPrefUtil (this ).setNotificationRegistrationID (s );
156
+ }
137
157
}
0 commit comments