Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions firebase.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ firebase.addAppDelegateMethods = function (appDelegate) {
// we need the launchOptions for this one so it's a bit hard to use the UIApplicationDidFinishLaunchingNotification pattern we're using for other things
appDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (application, launchOptions) {
// If the app was terminated and the iOS is launching it in result of push notification tapped by the user, this will hold the notification data.

if (FIROptions.defaultOptions() !== null) {
FIROptions.defaultOptions().deepLinkURLScheme = utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier;
}
FIRApp.configure();

if (launchOptions && typeof(FIRMessaging) !== "undefined") {
var remoteNotification = launchOptions.objectForKey(UIApplicationLaunchOptionsRemoteNotificationKey);
if (remoteNotification) {
Expand All @@ -76,7 +82,26 @@ firebase.addAppDelegateMethods = function (appDelegate) {

// there's no notification event to hook into for this one, so using the appDelegate
if (typeof(FBSDKApplicationDelegate) !== "undefined" || typeof(GIDSignIn) !== "undefined" || typeof(FIRInvites) !== "undefined" || typeof(FIRDynamicLink) !== "undefined") {
appDelegate.prototype.applicationOpenURLSourceApplicationAnnotation = function (application, url, sourceApplication, annotation) {

appDelegate.prototype.applicationContinueUserActivityRestorationHandler = function (application, userActivity, restorationhandler) {
var result = false;
console.log('got applicationContinueUserActivityRestorationHandler with '+ userActivity.webpageURL);
result = FIRDynamicLinks.dynamicLinks().handleUniversalLinkCompletion(userActivity.webpageURL, function(dynamicLink) {
if (dynamicLink && dynamicLink.url) {
if (firebase._dynamicLinkCallback) {
console.log('applicationContinueUserActivityRestorationHandler with _dynamicLinkCallback')
firebase._dynamicLinkCallback(dynamicLink.url.absoluteString);
} else {
console.log('applicationContinueUserActivityRestorationHandler without _dynamicLinkCallback')
firebase._cachedDynamicLink = dynamicLink.url.absoluteString;
}
}
});

return result;
};

appDelegate.prototype.applicationOpenURLSourceApplicationAnnotation = function (application, url, sourceApplication, annotation) {
var result = false;
if (typeof(FBSDKApplicationDelegate) !== "undefined") {
result = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation);
Expand All @@ -101,7 +126,8 @@ firebase.addAppDelegateMethods = function (appDelegate) {
if (typeof(FIRDynamicLink) !== "undefined") {
var dynamicLink = FIRDynamicLinks.dynamicLinks().dynamicLinkFromCustomSchemeURL(url)
if (dynamicLink) {
this._cachedDeepLink = dynamicLink.url.absoluteString;
console.log('applicationOpenURLSourceApplicationAnnotation without _dynamicLinkCallback')
firebase._cachedDynamicLink = dynamicLink.url.absoluteString;
result = true;
}
}
Expand Down Expand Up @@ -129,14 +155,16 @@ firebase.addAppDelegateMethods = function (appDelegate) {
}

if (typeof(FIRDynamicLink) !== "undefined") {
console.log(url);
var dynamicLink = FIRDynamicLinks.dynamicLinks().dynamicLinkFromCustomSchemeURL(url)
if (dynamicLink) {
console.log('applicationOpenURLOptions' + JSON.stringify(dynamicLink));
if (dynamicLink.url !== null) {
console.log(">>> dynamicLink.url.absoluteString: " + dynamicLink.url.absoluteString);
if (this._dynamicLinkCallback) {
this._dynamicLinkCallback(dynamicLink.url.absoluteString);
if (firebase._dynamicLinkCallback) {
firebase._dynamicLinkCallback(dynamicLink.url.absoluteString);
} else {
this._cachedDeepLink = dynamicLink.url.absoluteString;
firebase._cachedDynamicLink = dynamicLink.url.absoluteString;
}
result = true;
}
Expand Down Expand Up @@ -538,10 +566,10 @@ firebase.init = function (arg) {
arg = arg || {};

// if deeplinks are used, then for this scheme to work the use must have added the bundle as a scheme to their plist (this is in our docs)
if (FIROptions.defaultOptions() !== null) {
FIROptions.defaultOptions().deepLinkURLScheme = utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier;
}
FIRApp.configure();
// if (FIROptions.defaultOptions() !== null) {
// FIROptions.defaultOptions().deepLinkURLScheme = utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier;
// }
// FIRApp.configure();

if (arg.persist) {
FIRDatabase.database().persistenceEnabled = true;
Expand Down