Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
de-push-proxy-plugin / src / android / DEFCMIntentService.java
Size: Mime:
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;
    }
}