Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
vash15 committed Jul 12, 2019
1 parent a97d738 commit 43fa8ec
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
6 changes: 4 additions & 2 deletions src/android/FirebasePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
53 changes: 32 additions & 21 deletions src/ios/AppDelegate+FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
Expand Down Expand Up @@ -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(<FirebaseDynamicLinks/FirebaseDynamicLinks.h>)
handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) {
if ( dynamicLink ){
urlForSend = dynamicLink.url;
}
triggerHandleOpenUrl();
}];
#endif



Expand All @@ -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) {
Expand All @@ -204,17 +213,19 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification object:openURLData]];
};

#if __has_include(<FirebaseDynamicLinks/FirebaseDynamicLinks.h>)
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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
}

Expand Down

0 comments on commit 43fa8ec

Please sign in to comment.