This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
packages/firebase_messaging
android/src/main/java/io/flutter/plugins/firebasemessaging Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -208,6 +208,10 @@ public void run() {
208208 Boolean isEnabled = (Boolean ) call .arguments ();
209209 FirebaseMessaging .getInstance ().setAutoInitEnabled (isEnabled );
210210 result .success (null );
211+ } else if ("canRequestPermissions" .equals (call .method )) {
212+ result .success (null );
213+ } else if ("requestPermissions" .equals (call .method )) {
214+ result .success (null );
211215 } else {
212216 result .notImplemented ();
213217 }
Original file line number Diff line number Diff line change @@ -122,6 +122,20 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
122122 NSNumber *value = call.arguments ;
123123 [FIRMessaging messaging ].autoInitEnabled = value.boolValue ;
124124 result (nil );
125+ } else if ([@" requestPermissions" isEqualToString: method]) {
126+ BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL );
127+ if (canOpenSettings) {
128+ NSURL *url = [NSURL URLWithString: UIApplicationOpenSettingsURLString];
129+ [[UIApplication sharedApplication ] openURL: url];
130+ }
131+ result (nil );
132+ } else if ([@" canRequestPermissions" isEqualToString: method]) {
133+ BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL );
134+ if (canOpenSettings) {
135+ result ([NSNumber numberWithBool: YES ]);
136+ } else {
137+ result ([NSNumber numberWithBool: NO ]);
138+ }
125139 } else {
126140 result (FlutterMethodNotImplemented);
127141 }
Original file line number Diff line number Diff line change @@ -114,6 +114,14 @@ class FirebaseMessaging {
114114 await _channel.invokeMethod <void >('setAutoInitEnabled' , enabled);
115115 }
116116
117+ Future <bool > canRequestPermissions () async {
118+ return await _channel.invokeMethod ('canRequestPermissions' );
119+ }
120+
121+ Future <void > requestPermissions () async {
122+ await _channel.invokeMethod ('requestPermissions' );
123+ }
124+
117125 Future <dynamic > _handleMethod (MethodCall call) async {
118126 switch (call.method) {
119127 case "onToken" :
You can’t perform that action at this time.
0 commit comments