1
1
package com.onesignal
2
2
3
- import android.content.Context
4
3
4
+ import android.content.Context
5
5
import android.content.Intent
6
-
7
-
8
6
import com.amazon.device.messaging.ADMMessageHandlerJobBase
9
7
10
8
class ADMMessageHandlerJob : ADMMessageHandlerJobBase () {
11
- override fun onMessage (p0 : Context ? , p1 : Intent ? ) {
12
- TODO (" Not yet implemented" )
9
+
10
+ override fun onMessage (context : Context ? , intent : Intent ? ) {
11
+ val bundle = intent!! .extras
12
+
13
+ val processedResult = NotificationBundleProcessor .processBundleFromReceiver(context, bundle)
14
+ // TODO: Figure out the correct replacement or usage of completeWakefulIntent method
15
+ // FCMBroadcastReceiver.completeWakefulIntent(intent);
16
+
17
+ // TODO: Figure out the correct replacement or usage of completeWakefulIntent method
18
+ // FCMBroadcastReceiver.completeWakefulIntent(intent);
19
+ if (processedResult.processed()) return
20
+
21
+ val payload = NotificationBundleProcessor .bundleAsJSONObject(bundle)
22
+ val notification = OSNotification (payload)
23
+
24
+ val notificationJob = OSNotificationGenerationJob (context)
25
+ notificationJob.jsonPayload = payload
26
+ notificationJob.context = context
27
+ notificationJob.notification = notification
28
+ NotificationBundleProcessor .processJobForDisplay(notificationJob, true )
13
29
}
14
30
15
- override fun onRegistered (p0 : Context ? , p1 : String? ) {
16
- TODO (" Not yet implemented" )
31
+ override fun onRegistered (context : Context ? , newRegistrationId : String? ) {
32
+ OneSignal .Log (OneSignal .LOG_LEVEL .INFO , " ADM registration ID: $newRegistrationId " )
33
+ PushRegistratorADM .fireCallback(newRegistrationId)
17
34
}
18
35
19
- override fun onUnregistered (p0 : Context ? , p1 : String? ) {
20
- TODO ( " Not yet implemented " )
36
+ override fun onUnregistered (context : Context ? , registrationId : String? ) {
37
+ OneSignal . Log ( OneSignal . LOG_LEVEL . INFO , " ADM:onUnregistered: $registrationId " )
21
38
}
22
39
23
- override fun onRegistrationError (p0 : Context ? , p1 : String? ) {
24
- TODO (" Not yet implemented" )
40
+ override fun onRegistrationError (context : Context ? , error : String? ) {
41
+ OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , " ADM:onRegistrationError: $error " )
42
+ if (" INVALID_SENDER" == error) OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , " Please double check that you have a matching package name (NOTE: Case Sensitive), api_key.txt, and the apk was signed with the same Keystore and Alias." )
43
+
44
+ PushRegistratorADM .fireCallback(null )
25
45
}
26
46
}
0 commit comments