Android SDK Push-уведомление не работает - PullRequest
0 голосов
/ 15 марта 2019

Я пытался заставить мое приложение отправлять уведомления после настройки напоминания, но оно не работает. У меня были «устаревшие» проблемы, но после того, как я их решил, он все еще не работает. Это мой код:

public class AlarmNotificationReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

    String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);

    builder.setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL)
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.mipmap.ic_launcher_round)
            .setContentTitle("It's Yoga Time!")
            .setContentText("Time to train again.")
            .setContentInfo("Info");

    NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1,builder.build()); } }
...