通知を受け取ったときに音、振動または光が聞こえません。誰かが私に行方不明を教えてもらえますか?アプリが開いているとき、私は唯一の指定されたアイコンを取得Android:プッシュ通知に音/バイブレーション/ライトがありません
1):
また、私はいくつかの他の質問があります。アプリが閉じられるとアンドロイドのロゴアイコンが表示されます(まだアプリアイコンが定義されていないので、それは私が推測します)。
2.)テロップのテキストは、アプリが開いているときにのみ表示されます。
3.)アプリが開いているときは、コンテンツのテキストのみが表示されますが、コンテンツのタイトルは表示されません。
解決策:これは、以前のバージョンよりcom.google.android.gms:play-services-gcm:8.4.0
を使用しているために発生します。
サーバー上で、キー配列と値のペアe = 0のみを含む通知配列を送信している間は、データ配列にメッセージ情報を送信してください。
この問題は既にここに偉大な答えがあります。これは私のソースですAfter updating Google play services to 8.4.0 push notifications displayed by themselves
を:
public class MyGcmListenerService extends GcmListenerService {
private final static String TAG = "GCM_Listener";
@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from + " (" + message);
// Sets an ID for the notification
SharedPreferences sharedPreferences = getSharedPreferences(getString(R.string.sharedPreferenceStore_default), Context.MODE_PRIVATE);
int mNotificationId = sharedPreferences.getInt("id_notification", 0);
mNotificationId++;
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.all_picks_made_indicator)
.setAutoCancel(true)
.setContentTitle("Product - " + mNotificationId)
.setContentText(message)
.setTicker("Product Notification received");
// Because clicking the notification opens a new ("special") activity, there's no need to create an artificial back stack.
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, DetectLoginActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
Notification notification = mBuilder.build();
notification.defaults = Notification.DEFAULT_ALL;
mNotifyMgr.notify(mNotificationId, notification);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt("id_notification", mNotificationId);
editor.commit();
}
}
ありがとうございました! – Markus
私はアプリを殺したとき、振動のないプッシュ通知を受け取りました。他の状況では通知に振動があります。誰でもその理由を知っていますか? – nAkhmedov