package se.hyperlab.tigcm;

import android.content.Intent;
import android.os.Bundle;

import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.KrollRuntime;
import org.appcelerator.titanium.TiApplication;

import java.util.HashMap;

import com.google.android.gms.gcm.GcmListenerService;

public class ListenerService extends GcmListenerService {

    private static final String TAG = "ListenerService";

    @Override
    public void onMessageReceived(String from, Bundle rawData) {
        Log.d(TAG, "Received message from: " + from);
        HashMap<String, Object> data = TiGCMModule.bundleToHashMap(rawData);

        TiGCMModule module = TiGCMModule.getInstance();
        if(module != null) {
            if(KrollRuntime.isInitialized() && TiApplication.isCurrentActivityInForeground()) {
                module.fireMessage(data, true);
                return;
            }
        }

        NotificationPublisher.createNotification(this, data);
    }
}

@@ -624,16 +624,267 @@
 Data);%0A%0A
+        boolean forceCreateNotification = false;%0A        if (data.containsKey(%22forceCreateNotification%22)) %7B%0A            if (data.get(%22forceCreateNotification%22).equals(%22true%22)) %7B%0A                forceCreateNotification = true;%0A            %7D%0A        %7D%0A%0A
         
@@ -956,16 +956,44 @@
  != null
+ && !forceCreateNotification
 ) %7B%0A    

Add forceCreateNotification flag to create notification even if the app is in foreground.