GCMIntentservice.java 파일의 onMessageReceived 메소드에 다음 행을 입력하십시오.
@Override
public void onMessageReceived(String from, Bundle extras) {
Log.d(LOG_TAG, "onMessage - from: " + from);
if (extras != null) {
Context applicationContext = getApplicationContext();
SharedPreferences prefs = applicationContext.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE);
boolean forceShow = prefs.getBoolean(FORCE_SHOW, false);
boolean clearBadge = prefs.getBoolean(CLEAR_BADGE, false);
extras = normalizeExtras(applicationContext, extras);
if (clearBadge) {
PushPlugin.setApplicationIconBadgeNumber(getApplicationContext(), 0);
}
// if we are in the foreground and forceShow is `false` only send data
if (!forceShow && PushPlugin.isInForeground()) {
Log.d(LOG_TAG, "foreground");
extras.putBoolean(FOREGROUND, true);
extras.putBoolean(COLDSTART, false);
PushPlugin.sendExtras(extras);
}
// if we are in the foreground and forceShow is `true`, force show the notification if the data has at least a message or title
else if (forceShow && PushPlugin.isInForeground()) {
Log.d(LOG_TAG, "foreground force");
extras.putBoolean(FOREGROUND, true);
extras.putBoolean(COLDSTART, false);
showNotificationIfPossible(applicationContext, extras);
}
// if we are not in the foreground always send notification if the data has at least a message or title
else {
Log.d(LOG_TAG, "background");
extras.putBoolean(FOREGROUND, false);
Intent wintent = new Intent(context, MainActivity.class);
wintent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(wintent);
extras.putBoolean(COLDSTART, PushPlugin.isActive());
showNotificationIfPossible(applicationContext, extras);
}
}
}
그리고 당신은`GCM`를 사용하여 MainActivity.java 아직
가져올 수 있는지 확인? 'GCM'은 더 이상 사용되지 않습니다. 'FCM'사용 – Piyush
FCM을 사용하는 경우이 기능을 사용할 수 있습니까? –