Repository URL to install this package:
|
Version:
1.0.1 ▾
|
package com.vipera.pushproxy;
import android.os.Bundle;
import com.adobe.phonegap.push.FCMService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.List;
import java.util.Map;
/**
* Created by marcobonati on 22/05/2017.
*/
public class DEFCMIntentService extends FCMService {
public DEFCMIntentService(){
super();
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
List<DEPushNotificationHandler> handlers = DEPushNotificationHandlerRegistry.getInstance().getHandlers();
Bundle bundle = createDataBundle(remoteMessage.getData());
for (DEPushNotificationHandler handler:handlers){
try {
if (handler.canHandleMessage(remoteMessage.getFrom(), bundle)){
return;
}
} catch (Throwable th){
//TODO!! log
}
}
super.onMessageReceived(remoteMessage);
}
private Bundle createDataBundle(Map<String, String> data) {
if(data == null) {
return new Bundle();
}
Bundle bundle = new Bundle();
for (Map.Entry<String, String> entry : data.entrySet()) {
bundle.putString(entry.getKey(), entry.getValue());
}
return bundle;
}
}