I have been trying for days to get rid of Notifications Permission pop-up that appears in my Flutter app on first app run.
My code is the following:
void main() async {
await Hive.initFlutter();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
check_internet_connection();
super.initState();
}
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Myapp',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Text('test')
);
}
}
In general, I am using firebase and firebase messaging in my app.
While trying to disable the permission request, I wanted to see what causes the appearance of the pop-up window, hence I deleted almost everything (trial & error) from my main, leaving just the code above.
I am still getting the notifications permissions request on my iOS real device.
In my pubspec.yaml I have this: firebase_messaging: ^11.1.0
How can I disable the pop-up?
3
Answers
I think I have found why I have this behaviour. It is because of my AppDelegate.swift file where I have added this:
By removing the requestAuthorization() I don't get the pop-up anymore.
Faz answer helped me!! Additionally if you are using flutter_local_notifications plugin then you have to explicitly set it up to not to ask for permission by following way
For more information, please see this stackoverflow post and this issue along with this part of the readme.
In my case it was due to Flutter Badges. I was clearing firebase notification badges during app startup which in turn was requesting access to notifications
https://pub.dev/packages/badges