diff --git a/src/android/FirebasePlugin.java b/src/android/FirebasePlugin.java index 59c54d647..c2e3f10fc 100755 --- a/src/android/FirebasePlugin.java +++ b/src/android/FirebasePlugin.java @@ -730,8 +730,10 @@ public void run() { StackTraceElement[] trace = new StackTraceElement[stackTrace.length()]; for(int i = 0; i < stackTrace.length(); i++) { JSONObject elem = stackTrace.getJSONObject(i); - - trace[i] = new StackTraceElement("undefined", elem.getString("functionName"),elem.getString("fileName"), elem.getInt("lineNumber")); + String functionName = elem.has("functionName") ? elem.getString("functionName") : ""; + String fileName = elem.has("fileName") ? elem.getString("fileName") : ""; + int lineNumber = elem.has("lineNumber") ? elem.getInt("lineNumber") : 0; + trace[i] = new StackTraceElement("undefined", functionName, fileName, lineNumber); } JavaScriptException ex = new JavaScriptException(data.getString(0)); diff --git a/src/ios/AppDelegate+FirebasePlugin.m b/src/ios/AppDelegate+FirebasePlugin.m index 7dab296a6..5e1dcb249 100755 --- a/src/ios/AppDelegate+FirebasePlugin.m +++ b/src/ios/AppDelegate+FirebasePlugin.m @@ -49,17 +49,17 @@ - (BOOL)application:(UIApplication *)application swizzledDidFinishLaunchingWithO // get GoogleService-Info.plist file path NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"]; - + // if file is successfully found, use it if(filePath){ NSLog(@"GoogleService-Info.plist found, setup: [FIRApp configureWithOptions]"); // create firebase configure options passing .plist as content FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath]; - + // configure FIRApp with options [FIRApp configureWithOptions:options]; } - + // no .plist found, try default App if (![FIRApp defaultApp] && !filePath) { NSLog(@"GoogleService-Info.plist NOT FOUND, setup: [FIRApp defaultApp]"); @@ -154,17 +154,23 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull N #endif // __IPHONE_12_0 __block NSURL *urlForSend = userActivity.webpageURL; - dispatch_block_t triggerHandleOpenUrl = ^(void) { + void (^triggerHandleOpenUrl)(void) = ^{ + if ( urlForSend == nil ) + return; [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:urlForSend]]; }; - BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) { - if ( dynamicLink ){ - urlForSend = dynamicLink.url; - } - triggerHandleOpenUrl(); - }]; + + BOOL handled = false; + #if __has_include() + handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) { + if ( dynamicLink ){ + urlForSend = dynamicLink.url; + } + triggerHandleOpenUrl(); + }]; + #endif @@ -187,8 +193,11 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { - NSURL *urlForSend = url; // Initialize with current url - dispatch_block_t triggerHandleOpenUrl = ^(void) { + __block NSURL *urlForSend = nil; // Initialize with current url + void (^triggerHandleOpenUrl)(void) = ^{ + if ( urlForSend == nil ) + return; + NSMutableDictionary * openURLData = [[NSMutableDictionary alloc] init]; [openURLData setValue:urlForSend forKey:@"url"]; if (sourceApplication) { @@ -204,17 +213,19 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification object:openURLData]]; }; + #if __has_include() + FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url]; - FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url]; - - // check if url passed is a Firebase Dynamic Link - if (dynamicLink) { - // Recover the url or deeplink from Firebase Dynamic Link - urlForSend = dynamicLink.url; - triggerHandleOpenUrl(); - return YES; - } + // check if url passed is a Firebase Dynamic Link + if (dynamicLink) { + // Recover the url or deeplink from Firebase Dynamic Link + urlForSend = dynamicLink.url; + triggerHandleOpenUrl(); + return YES; + } + #endif + urlForSend = url; triggerHandleOpenUrl(); return NO; } diff --git a/src/ios/FirebasePlugin.m b/src/ios/FirebasePlugin.m index 94568690c..5c6eb9c59 100644 --- a/src/ios/FirebasePlugin.m +++ b/src/ios/FirebasePlugin.m @@ -43,7 +43,7 @@ - (void)pluginInitialize { NSString* allowFileAccess = [self.commandDelegate.settings objectForKey:[@"FirebasePluginAllowFileAccess" lowercaseString]]; if ([self.webView isKindOfClass:WKWebView.class] && [allowFileAccess isEqualToString:@"true"]){ WKWebView *wkWebView = (WKWebView *) self.webView; - [wkWebView.configuration.preferences setValue:@"true" forKey:@"allowFileAccessFromFileURLs"]; + [wkWebView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"]; } }