package se.hyperlab.tigcm;

import android.content.Intent;
import android.app.Activity;
import android.os.Bundle;
import org.appcelerator.kroll.common.Log;

import org.appcelerator.titanium.TiApplication;

import java.util.HashMap;

public class NotificationActivity extends Activity {

    private static final String TAG = "NotificationActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();
        HashMap<String, Object> data = (HashMap)intent.getSerializableExtra(TiGCMModule.NTF_KEY_DATA);

        TiGCMModule module = TiGCMModule.getInstance();
        TiApplication instance = TiApplication.getInstance();

        if(module != null) {
            module.fireMessage(data, false);
        } else {
            TiApplication.getInstance().getAppProperties().setString(TiGCMModule.PROPERTY_PENDING_DATA, data.toString());
            Log.d(TAG, "Saving data in props: " + data.toString());
        }

        String pkg = instance.getApplicationContext().getPackageName();
        Intent launcherIntent = instance.getApplicationContext().getPackageManager().getLaunchIntentForPackage(pkg);

        startActivity(launcherIntent);
        finish();
    }
}

@@ -197,16 +197,57 @@
 ication;
+%0Aimport org.appcelerator.kroll.KrollDict;
 %0A%0Aimport
@@ -851,16 +851,68 @@
  else %7B%0A
+            KrollDict kdata = new KrollDict(data);%0A%0A
         
@@ -1007,16 +1007,17 @@
 G_DATA, 
+k
 data.toS
@@ -1076,16 +1076,17 @@
 ps: %22 + 
+k
 data.toS

Fix data serialization causing app not to receive data when launched from notification