This is by design, if you want to receive notifications only when the app is open you need to the following in your activity that extends DroidGap:
package com.xtify.cordova.samples;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Bundle;
import com.xtify.cordova.XtifyCordovaPlugin;
import com.xtify.sdk.api.XtifyBroadcastReceiver;
public class MainActivity extends org.apache.cordova.DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
@Override
protected void onResume() {
super.onResume();
this.registerReceiver(this.xtifyReceiver, new IntentFilter(
"com.xtify.sdk.NOTIFIER"));
}
@Override
protected void onPause() {
super.onPause();
this.unregisterReceiver(this.xtifyReceiver);
}
private XtifyBroadcastReceiver xtifyReceiver = new XtifyBroadcastReceiver() {
@Override
protected void onRegistered(Context arg0) {
// no-op
}
@Override
protected void onMessage(Context arg0, Bundle msgExtras) {
XtifyCordovaPlugin.processActivityExtras(msgExtras,
MainActivity.this);
}
@Override
protected void onC2dmError(Context arg0, String arg1) {
// no-op
}
};
}
And also you need to modify com.xtify.cordova.XtifyCordovaPlugin.processActivityExtras method to the following :
public static void processActivityExtras(Bundle msgExtras, DroidGap dg) {
if (msgExtras != null && (msgExtras.getString("com.xtify.sdk.NOTIFICATION_TITLE") != null)) {
try {
JSONObject data = new JSONObject();
for (String key : msgExtras.keySet()) {
data.put(key, msgExtras.getString(key));
}
Context context = dg.getApplicationContext().getApplicationContext();
String eventCallBackName = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).getString(KEY_CALLBACK, "");
String js = "javascript:" + eventCallBackName + "(" + data.toString() + ")";
dg.sendJavascript(js);
} catch (JSONException e) {
Log.e(TAG, "Error processing activity extras", e);
}
}
}
Also make sure you set the notification action to NONE in the Xtify console or in the Push API.