Skip to content

Commit

Permalink
fix: request POST_NOTIFICATIONS permission for setting destination re…
Browse files Browse the repository at this point in the history
…minders

Signed-off-by: Amr Hossam <[email protected]>
  • Loading branch information
amrhossamdev authored and aaronbrethorst committed Sep 1, 2024
1 parent f530ab2 commit 387a185
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.onebusaway.android.ui;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
Expand Down Expand Up @@ -53,6 +54,7 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.AsyncTaskLoader;
Expand Down Expand Up @@ -96,6 +98,8 @@
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;

import static org.onebusaway.android.util.PermissionUtils.NOTIFICATION_PERMISSION_REQUEST;

public class TripDetailsListFragment extends ListFragment {

public static final String TAG = "TripDetailsListFragment";
Expand Down Expand Up @@ -554,6 +558,12 @@ public void onClick(DialogInterface dialog, int which) {

ObaAnalytics.reportUiEvent(mFirebaseAnalytics, getString(R.string.analytics_label_destination_reminder), getString(R.string.analytics_label_destination_reminder_variant_started));

// Request the user to grant the POST_NOTIFICATIONS permission.
ActivityCompat.requestPermissions(getActivity(),
new String[] {Manifest.permission.POST_NOTIFICATIONS},
NOTIFICATION_PERMISSION_REQUEST);
dialog.dismiss();

startNavigationService(setUpNavigationService(position));
Toast.makeText(Application.get(),
Application.get().getString(R.string.destination_reminder_title),
Expand Down

0 comments on commit 387a185

Please sign in to comment.