Реализация кнопок действий для отправки уведомлений в Android

Я реализовал все из этого руководства, https://phonegapppro.com/tutorials/apache-cordova-phonegap-push-notification-tutorial-part-3/ . Я пытаюсь реализовать push-уведомления с кнопками действий «Да», «Нет», результат которых будет отправлен обратно в базу данных после нажатия. Однако я прошел через множество руководств и не смог реализовать эти кнопки действий в своем push-уведомлении.

GCMintentService.java

    public void createNotification(Context context, Bundle extras) {
    NotificationManager mNotificationManager = (NotificationManager)             getSystemService(Context.NOTIFICATION_SERVICE);
    String appName = getAppName(this);
    String packageName = context.getPackageName();
    Resources resources = context.getResources();

    int notId = parseInt(NOT_ID, extras);
    Intent notificationIntent = new Intent(this, PushHandlerActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra(PUSH_BUNDLE, extras);
    notificationIntent.putExtra(NOT_ID, notId);

    int requestCode = new Random().nextInt();
    PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setWhen(System.currentTimeMillis())
                    .setContentTitle(fromHtml(extras.getString(TITLE)))
                    .setTicker(fromHtml(extras.getString(TITLE)))
                    .setContentIntent(contentIntent)
                    .setAutoCancel(true);

    SharedPreferences prefs = context.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE);
    String localIcon = prefs.getString(ICON, null);
    String localIconColor = prefs.getString(ICON_COLOR, null);
    boolean soundOption = prefs.getBoolean(SOUND, true);
    boolean vibrateOption = prefs.getBoolean(VIBRATE, true);
    Log.d(LOG_TAG, "stored icon=" + localIcon);
    Log.d(LOG_TAG, "stored iconColor=" + localIconColor);
    Log.d(LOG_TAG, "stored sound=" + soundOption);
    Log.d(LOG_TAG, "stored vibrate=" + vibrateOption);

    /*
     * Notification Vibration
     */

    setNotificationVibration(extras, vibrateOption, mBuilder);

    /*
     * Notification Icon Color
     *
     * Sets the small-icon background color of the notification.
     * To use, add the `iconColor` key to plugin android options
     *
     */
    setNotificationIconColor(extras.getString("color"), mBuilder, localIconColor);

    /*
     * Notification Icon
     *
     * Sets the small-icon of the notification.
     *
     * - checks the plugin options for `icon` key
     * - if none, uses the application icon
     *
     * The icon value must be a string that maps to a drawable resource.
     * If no resource is found, falls
     *
     */
    setNotificationSmallIcon(context, extras, packageName, resources, mBuilder, localIcon);

    /*
     * Notification Large-Icon
     *
     * Sets the large-icon of the notification
     *
     * - checks the gcm data for the `image` key
     * - checks to see if remote image, loads it.
     * - checks to see if assets image, Loads It.
     * - checks to see if resource image, LOADS IT!
     * - if none, we don't set the large icon
     *
     */
    setNotificationLargeIcon(extras, packageName, resources, mBuilder);

    /*
     * Notification Sound
     */
    if (soundOption) {
        setNotificationSound(context, extras, mBuilder);
    }

    /*
     *  LED Notification
     */
    setNotificationLedColor(extras, mBuilder);

    /*
     *  Priority Notification
     */
    setNotificationPriority(extras, mBuilder);

    /*
     * Notification message
     */
    setNotificationMessage(notId, extras, mBuilder);

    /*
     * Notification count
     */
    setNotificationCount(context, extras, mBuilder);

    /*
     * Notification count
     */
    setVisibility(context, extras, mBuilder);

    /*
     * Notification add actions
     */
    createActions(extras, mBuilder, resources, packageName, notId);

    mNotificationManager.notify(appName, notId, mBuilder.build());
}

person Xinee    schedule 30.11.2016    source источник
comment
вы должны использовать .addAction(R.drawable.yes, Yes, pendingIntentYes);   -  person Divyesh Patel    schedule 30.11.2016
comment
Привет, спасибо за ответ! Однако после добавления этой строки ниже моего .set я получаю сообщение об ошибке с кодами ошибок: недопустимое начало выражения, сбой выполнения для задачи ':compileDebugJavaWithJavac'.   -  person Xinee    schedule 30.11.2016
comment
Поместите эту строку раньше. SetAutoCancel в построителе уведомлений   -  person Divyesh Patel    schedule 30.11.2016
comment
NotificationCompat.Builder mBuilder = новый NotificationCompat.Builder(контекст) .addAction(R.drawable.yes, Да, pendingIntentYes); .setWhen(System.currentTimeMillis()) .setContentTitle(fromHtml(extras.getString(TITLE))) .setTicker(fromHtml(extras.getString(TITLE))) .setContentIntent(contentIntent) .setAutoCancel(true);   -  person Xinee    schedule 30.11.2016
comment
жаль все еще не работает. Я новичок в этом и не очень уверен, как реализовать   -  person Xinee    schedule 30.11.2016
comment
Вы должны определить это рисование и создать новое ожидающее намерение с именем pendingIntentYes   -  person Divyesh Patel    schedule 30.11.2016
comment
Да, я считаю, что это проблема. Как я могу это сделать?   -  person Xinee    schedule 30.11.2016
comment
что такое диалоговый плагин?   -  person Divyesh Patel    schedule 03.12.2016
comment
Я установил Cordova-plugin-dialogs и сделал что-то вроде этого push.on('notification', function(data) { navigator.notification.confirm( data.message, // сообщение onConfirm, // обратный вызов для вызова с индексом нажатой кнопки data.title, // заголовок ['Нет', 'Да'] // метки кнопок ); });   -  person Xinee    schedule 03.12.2016