skip to Main Content

I want to ask the user this type of promt in both the android and ios ,when the user come inside my app. But im not able to achive it. So if some one know please help me with this. Thank you in advance.

Tried using permission_handler package but not able to see the permission dialog

2

Answers


  1. You can use this code for permission in flutter.

    Future<PermissionStatus> permissionStatus = NotificationPermissions.requestNotificationPermissions({NotificationSettingsIos iosSettings, bool openSettings});
    

    You also need to configure permission for notification in iOS in xcode by enabling push notification.

    Login or Signup to reply.
  2. void requestNotificationPermission() async {
    NotificationSettings settings = await messaging.requestPermission(
    alert: true,
    announcement: true,
    badge: true,
    carPlay: true,
    criticalAlert: true,
    provisional: true,
    sound: true,
    );

    if (settings.authorizationStatus == AuthorizationStatus.authorized) {
      if (kDebugMode) {
        print('user granted permission');
      }
    } else if (settings.authorizationStatus ==
        AuthorizationStatus.provisional) {
      if (kDebugMode) {
        print('user granted provisional permission');
      }
    } else {
      //appsetting.AppSettings.openNotificationSettings();
      if (kDebugMode) {
        print('user denied permission');
      }
    }
    

    }

    add it in any init function it will show the permission Dialog for the notification

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search