package com.globo.reactnativeua;

import android.util.Log;

import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import com.urbanairship.push.PushMessage;

class ReactNativeUAEventEmitter {

    private static final String TAG = "ReactNativeUAEventEmitter";

	private static ReactNativeUAEventEmitter INSTANCE = null;

	private ReactContext context;

	private ReactNativeUAEventEmitter(ReactContext reactContext) {
    	this.context = reactContext;
	}

	private void sendEvent(String eventName, String message) {
		Log.d(TAG, "Sending notification: " + message);
		this.context
			.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
			.emit(eventName, message);
	}

	public void sendEvent(String eventName, PushMessage message) {
		this.sendEvent(eventName, message.getAlert());
	}

	public static void setup(ReactContext reactContext) {
		if (ReactNativeUAEventEmitter.INSTANCE == null) {
			ReactNativeUAEventEmitter.INSTANCE = new ReactNativeUAEventEmitter(reactContext);
			return;
		} else {
			Log.w(TAG, "Event Emmitter initialized more than once");
			return;
		}
	}

	public static ReactNativeUAEventEmitter getInstance() {
		return ReactNativeUAEventEmitter.INSTANCE;
	}
}

@@ -53,16 +53,106 @@
 l.Log;%0A%0A
+import com.facebook.react.bridge.Arguments;%0Aimport com.facebook.react.bridge.ReadableMap;%0A
 import c
@@ -190,16 +190,16 @@
 ontext;%0A
-
 import c
@@ -605,16 +605,195 @@
 private 
+ReadableMap createReactNativeMessageObject(PushMessage message) %7B%0A%09%09ReadableMap messageObject = Arguments.fromBundle(message.getPushBundle());%0A%09%09return messageObject;%0A%09%7D%0A%0A%09public 
 void sen
@@ -817,22 +817,27 @@
 ntName, 
-String
+ReadableMap
  message
@@ -842,16 +842,18 @@
 ge) %7B%0A%09%09
+//
 Log.d(TA
@@ -1107,25 +1107,51 @@
 me, 
-message.getAlert(
+this.createReactNativeMessageObject(message
 ));%0A

send push message bundle to JS