ステータスバーの通知を取得するために別のプラグインを使用しました:
https://github.com/phonegap/phonegap-plugins/tree/master/Android/StatusBarNotification
次に、デバイスの gcm Java スクリプトの on receive 関数に、次のコード行を追加します。
window.plugins.statusBarNotification.notify("ここにタイトルを入力してください", "ここにメッセージを入力してください");
正常に動作する唯一の問題は、デバイスをスリープ解除する方法です...見つけたらすぐに回答を投稿します。
デバイスをスリープ解除する方法を見つけました。申し訳ありませんが、返信をすぐに投稿するのを忘れていました。
秘訣は、JAVA コードの GCM サービスの受信者モジュールで保留中の意図を作成することでした。保留中の意図は、アプリケーションのメイン アクティビティであるアクティビティによって受信され、アクティビティは RAM にロードされます。次に、GCM サービスは 5 秒間待機して、メインのアクティビティの読み込みが完了するようにします...そして通知を受け取り、それを cordova に送信します...私にとってはうまくいきますが、レイズする前にアクティビティが既に実行されているかどうかを確認することもできます。保留中の意図。
GCM サービスのコードを以下に追加します。
//Intent notifyIntent = new Intent("com.cordova2.gcm.MainActivity");
Context context2 = getApplicationContext();
PendingIntent pendingIntent;
Intent notifyIntent = new Intent();
notifyIntent.setClass(context2, com.cordova2.gcm.MainActivity.class);
pendingIntent = PendingIntent.getActivity(context2, 0, notifyIntent, 0);
try {
pendingIntent.send();
} catch (CanceledException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
long endTime = System.currentTimeMillis() + 5*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}