ios: Make oAuth callback urls work

I'm getting some exceptions in the middle, but it still seems to work.
This commit is contained in:
Vishesh Handa
2019-06-04 02:02:41 +02:00
parent 1389fba579
commit 7403721753
2 changed files with 28 additions and 2 deletions

View File

@ -12,6 +12,8 @@ NSString* GetDirectoryOfType(NSSearchPathDirectory dir) {
return paths.firstObject; return paths.firstObject;
} }
static FlutterMethodChannel* gitChannel = 0;
@implementation AppDelegate @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@ -20,8 +22,8 @@ NSString* GetDirectoryOfType(NSSearchPathDirectory dir) {
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController; FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
FlutterMethodChannel* gitChannel = [FlutterMethodChannel gitChannel = [FlutterMethodChannel methodChannelWithName:@"gitjournal.io/git"
methodChannelWithName:@"gitjournal.io/git" binaryMessenger:controller]; binaryMessenger:controller];
[gitChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { [gitChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
NSString *method = [call method]; NSString *method = [call method];
@ -440,4 +442,17 @@ bool handleError(FlutterResult result, int err) {
} }
} }
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
NSLog(@"openUrl called with url %@", url);
for (NSString *key in [options allKeys]) {
NSLog(@". %@: %@", key, [options objectForKey:key]);
}
NSDictionary *args = @{@"URL": [url absoluteString]};
[gitChannel invokeMethod:@"onURL" arguments:args];
return true;
}
@end @end

View File

@ -2,6 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>io.gitjournal.gitjournal</string>
<key>CFBundleURLSchemes</key>
<array>
<string>gitjournal</string>
</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>