Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 42d4dfd

Browse files
committed
(docs): Added JSDoc to function added
1 parent 942e64f commit 42d4dfd

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

firebase.ios.js

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ firebase._gIDAuthentication = null;
1414
firebase._cachedInvitation = null;
1515
firebase._cachedDynamicLink = null;
1616

17+
/**
18+
* Workaround function to call the `dispatch_get_main_queue(...)` for iOS
19+
* thanks to Alexander Ziskind found on:
20+
* http://nuvious.com/Blog/2016/7/5/calling-dispatch_async-in-nativescript
21+
*/
1722
let invokeOnRunLoop = (function () {
1823
var runloop = CFRunLoopGetMain();
1924
return function (func) {
@@ -51,7 +56,7 @@ function handleRemoteNotification(app, userInfo) {
5156
}
5257

5358
function addBackgroundRemoteNotificationHandler(appDelegate) {
54-
if (typeof (FIRMessaging) !== "undefined") {
59+
if (typeof(FIRMessaging) !== "undefined") {
5560
appDelegate.prototype.applicationDidReceiveRemoteNotificationFetchCompletionHandler = function (app, notification, completionHandler) {
5661
// Pass notification to auth and check if they can handle it (in case phone auth is being used), see https://firebase.google.com/docs/auth/ios/phone-auth
5762
if (FIRAuth.auth().canHandleNotification(notification)) {
@@ -69,32 +74,32 @@ firebase.addAppDelegateMethods = function (appDelegate) {
6974
// we need the launchOptions for this one so it's a bit hard to use the UIApplicationDidFinishLaunchingNotification pattern we're using for other things
7075
appDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (application, launchOptions) {
7176
// 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.
72-
if (launchOptions && typeof (FIRMessaging) !== "undefined") {
77+
if (launchOptions && typeof(FIRMessaging) !== "undefined") {
7378
var remoteNotification = launchOptions.objectForKey(UIApplicationLaunchOptionsRemoteNotificationKey);
7479
if (remoteNotification) {
7580
handleRemoteNotification(application, remoteNotification);
7681
}
7782
}
7883
// Firebase Facebook authentication
79-
if (typeof (FBSDKApplicationDelegate) !== "undefined") {
84+
if (typeof(FBSDKApplicationDelegate) !== "undefined") {
8085
FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application, launchOptions);
8186
}
8287
return true;
8388
};
8489

8590
// there's no notification event to hook into for this one, so using the appDelegate
86-
if (typeof (FBSDKApplicationDelegate) !== "undefined" || typeof (GIDSignIn) !== "undefined" || typeof (FIRInvites) !== "undefined" || typeof (FIRDynamicLink) !== "undefined") {
91+
if (typeof(FBSDKApplicationDelegate) !== "undefined" || typeof(GIDSignIn) !== "undefined" || typeof(FIRInvites) !== "undefined" || typeof(FIRDynamicLink) !== "undefined") {
8792
appDelegate.prototype.applicationOpenURLSourceApplicationAnnotation = function (application, url, sourceApplication, annotation) {
8893
var result = false;
89-
if (typeof (FBSDKApplicationDelegate) !== "undefined") {
94+
if (typeof(FBSDKApplicationDelegate) !== "undefined") {
9095
result = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation);
9196
}
9297

93-
if (typeof (GIDSignIn) !== "undefined") {
98+
if (typeof(GIDSignIn) !== "undefined") {
9499
result = result || GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(url, sourceApplication, annotation);
95100
}
96101

97-
if (typeof (FIRInvites) !== "undefined") {
102+
if (typeof(FIRInvites) !== "undefined") {
98103
var receivedInvite = FIRInvites.handleURLSourceApplicationAnnotation(url, sourceApplication, annotation);
99104
if (receivedInvite) {
100105
console.log("Deep link from " + sourceApplication + ", Invite ID: " + invite.invideId + ", App URL: " + invite.deepLink);
@@ -106,7 +111,7 @@ firebase.addAppDelegateMethods = function (appDelegate) {
106111
}
107112
}
108113

109-
if (typeof (FIRDynamicLink) !== "undefined") {
114+
if (typeof(FIRDynamicLink) !== "undefined") {
110115
var dynamicLink = FIRDynamicLinks.dynamicLinks().dynamicLinkFromCustomSchemeURL(url)
111116
if (dynamicLink) {
112117
this._cachedDeepLink = dynamicLink.url.absoluteString;
@@ -118,25 +123,25 @@ firebase.addAppDelegateMethods = function (appDelegate) {
118123
};
119124
}
120125

121-
if (typeof (FBSDKApplicationDelegate) !== "undefined" || typeof (GIDSignIn) !== "undefined" || typeof (FIRDynamicLink) !== "undefined") {
126+
if (typeof(FBSDKApplicationDelegate) !== "undefined" || typeof(GIDSignIn) !== "undefined" || typeof(FIRDynamicLink) !== "undefined") {
122127
appDelegate.prototype.applicationOpenURLOptions = function (application, url, options) {
123128
var result = false;
124-
if (typeof (FBSDKApplicationDelegate) !== "undefined") {
129+
if (typeof(FBSDKApplicationDelegate) !== "undefined") {
125130
result = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(
126131
application,
127132
url,
128133
options.valueForKey(UIApplicationOpenURLOptionsSourceApplicationKey),
129134
options.valueForKey(UIApplicationOpenURLOptionsAnnotationKey));
130135
}
131136

132-
if (typeof (GIDSignIn) !== "undefined") {
137+
if (typeof(GIDSignIn) !== "undefined") {
133138
result = result || GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(
134139
url,
135140
options.valueForKey(UIApplicationOpenURLOptionsSourceApplicationKey),
136141
options.valueForKey(UIApplicationOpenURLOptionsAnnotationKey));
137142
}
138143

139-
if (typeof (FIRDynamicLink) !== "undefined") {
144+
if (typeof(FIRDynamicLink) !== "undefined") {
140145
var dynamicLink = FIRDynamicLinks.dynamicLinks().dynamicLinkFromCustomSchemeURL(url)
141146
if (dynamicLink) {
142147
if (dynamicLink.url !== null) {
@@ -161,7 +166,7 @@ firebase.addAppDelegateMethods = function (appDelegate) {
161166
firebase.fetchProvidersForEmail = function (email) {
162167
return new Promise(function (resolve, reject) {
163168
try {
164-
if (typeof (email) !== "string") {
169+
if (typeof(email) !== "string") {
165170
reject("A parameter representing an email address is required.");
166171
return;
167172
}
@@ -183,7 +188,7 @@ firebase.fetchProvidersForEmail = function (email) {
183188
firebase.getCurrentPushToken = function () {
184189
return new Promise(function (resolve, reject) {
185190
try {
186-
if (typeof (FIRMessaging) === "undefined") {
191+
if (typeof(FIRMessaging) === "undefined") {
187192
reject("Enable FIRMessaging in Podfile first");
188193
return;
189194
}
@@ -199,7 +204,7 @@ firebase.getCurrentPushToken = function () {
199204
firebase.addOnMessageReceivedCallback = function (callback) {
200205
return new Promise(function (resolve, reject) {
201206
try {
202-
if (typeof (FIRMessaging) === "undefined") {
207+
if (typeof(FIRMessaging) === "undefined") {
203208
reject("Enable FIRMessaging in Podfile first");
204209
return;
205210
}
@@ -219,7 +224,7 @@ firebase.addOnMessageReceivedCallback = function (callback) {
219224
firebase.addOnDynamicLinkReceivedCallback = function (callback) {
220225
return new Promise(function (resolve, reject) {
221226
try {
222-
if (typeof (FIRDynamicLink) === "undefined") {
227+
if (typeof(FIRDynamicLink) === "undefined") {
223228
reject("Enable FIRInvites in Podfile first");
224229
return;
225230
}
@@ -243,7 +248,7 @@ firebase.addOnDynamicLinkReceivedCallback = function (callback) {
243248
firebase.addOnPushTokenReceivedCallback = function (callback) {
244249
return new Promise(function (resolve, reject) {
245250
try {
246-
if (typeof (FIRMessaging) === "undefined") {
251+
if (typeof(FIRMessaging) === "undefined") {
247252
reject("Enable FIRMessaging in Podfile first");
248253
return;
249254
}
@@ -268,7 +273,7 @@ firebase.addOnPushTokenReceivedCallback = function (callback) {
268273
firebase.unregisterForPushNotifications = function (callback) {
269274
return new Promise(function (resolve, reject) {
270275
try {
271-
if (typeof (FIRMessaging) === "undefined") {
276+
if (typeof(FIRMessaging) === "undefined") {
272277
reject("Enable FIRMessaging in Podfile first");
273278
return;
274279
}
@@ -437,7 +442,7 @@ function getAppDelegate() {
437442

438443
// rather than hijacking the appDelegate for these we'll be a good citizen and listen to the notifications
439444
function prepAppDelegate() {
440-
if (typeof (FIRMessaging) !== "undefined") {
445+
if (typeof(FIRMessaging) !== "undefined") {
441446
// see https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/178 for why we're not using a constant here
442447
firebase._addObserver("com.firebase.iid.notif.refresh-token", firebase._onTokenRefreshNotification);
443448

@@ -600,12 +605,12 @@ firebase.init = function (arg) {
600605
}
601606

602607
// Facebook Auth
603-
if (typeof (FBSDKAppEvents) !== "undefined") {
608+
if (typeof(FBSDKAppEvents) !== "undefined") {
604609
FBSDKAppEvents.activateApp();
605610
}
606611

607612
// Firebase notifications (FCM)
608-
if (typeof (FIRMessaging) !== "undefined") {
613+
if (typeof(FIRMessaging) !== "undefined") {
609614
if (arg.onMessageReceivedCallback !== undefined || arg.onPushTokenReceivedCallback !== undefined) {
610615
if (arg.onMessageReceivedCallback !== undefined) {
611616
firebase.addOnMessageReceivedCallback(arg.onMessageReceivedCallback);
@@ -618,7 +623,7 @@ firebase.init = function (arg) {
618623

619624
// Firebase storage
620625
if (arg.storageBucket) {
621-
if (typeof (FIRStorage) === "undefined") {
626+
if (typeof(FIRStorage) === "undefined") {
622627
reject("Uncomment Storage in the plugin's Podfile first");
623628
return;
624629
}
@@ -707,7 +712,7 @@ firebase.analytics.setScreenName = function (arg) {
707712
firebase.admob.showBanner = function (arg) {
708713
return new Promise(function (resolve, reject) {
709714
try {
710-
if (typeof (GADRequest) === "undefined") {
715+
if (typeof(GADRequest) === "undefined") {
711716
reject("Uncomment AdMob in the plugin's Podfile first");
712717
return;
713718
}
@@ -777,7 +782,7 @@ firebase.admob.showBanner = function (arg) {
777782
firebase.admob.showInterstitial = function (arg) {
778783
return new Promise(function (resolve, reject) {
779784
try {
780-
if (typeof (GADRequest) === "undefined") {
785+
if (typeof(GADRequest) === "undefined") {
781786
reject("Uncomment AdMob in the plugin's Podfile first");
782787
return;
783788
}
@@ -935,7 +940,7 @@ firebase.admob._getBannerType = function (size) {
935940
firebase.getRemoteConfig = function (arg) {
936941
return new Promise(function (resolve, reject) {
937942
try {
938-
if (typeof (FIRRemoteConfig) === "undefined") {
943+
if (typeof(FIRRemoteConfig) === "undefined") {
939944
reject("Uncomment RemoteConfig in the plugin's Podfile first");
940945
return;
941946
}
@@ -1057,11 +1062,11 @@ firebase.logout = function (arg) {
10571062
FIRAuth.auth().signOut(null);
10581063

10591064
// also disconnect from Google otherwise ppl can't connect with a different account
1060-
if (typeof (GIDSignIn) !== "undefined") {
1065+
if (typeof(GIDSignIn) !== "undefined") {
10611066
GIDSignIn.sharedInstance().disconnect();
10621067
}
10631068

1064-
if (typeof (FBSDKLoginManager) !== "undefined") {
1069+
if (typeof(FBSDKLoginManager) !== "undefined") {
10651070
FBSDKLoginManager.alloc().logOut();
10661071
}
10671072

@@ -1145,7 +1150,7 @@ firebase.login = function (arg) {
11451150
var onCompletion = function (user, error) {
11461151
if (error) {
11471152
// also disconnect from Google otherwise ppl can't connect with a different account
1148-
if (typeof (GIDSignIn) !== "undefined") {
1153+
if (typeof(GIDSignIn) !== "undefined") {
11491154
GIDSignIn.sharedInstance().disconnect();
11501155
}
11511156
reject(error.localizedDescription);
@@ -1245,7 +1250,7 @@ firebase.login = function (arg) {
12451250
}
12461251

12471252
} else if (arg.type === firebase.LoginType.FACEBOOK) {
1248-
if (typeof (FBSDKLoginManager) === "undefined") {
1253+
if (typeof(FBSDKLoginManager) === "undefined") {
12491254
reject("Facebook SDK not installed - see Podfile");
12501255
return;
12511256
}
@@ -1294,7 +1299,7 @@ firebase.login = function (arg) {
12941299
onFacebookCompletion);
12951300

12961301
} else if (arg.type === firebase.LoginType.GOOGLE) {
1297-
if (typeof (GIDSignIn) === "undefined") {
1302+
if (typeof(GIDSignIn) === "undefined") {
12981303
reject("Google Sign In not installed - see Podfile");
12991304
return;
13001305
}
@@ -1832,7 +1837,7 @@ firebase.remove = function (path) {
18321837
};
18331838

18341839
function getStorageRef(reject, arg) {
1835-
if (typeof (FIRStorage) === "undefined") {
1840+
if (typeof(FIRStorage) === "undefined") {
18361841
reject("Uncomment Storage in the plugin's Podfile first");
18371842
return;
18381843
}
@@ -1881,7 +1886,7 @@ firebase.uploadFile = function (arg) {
18811886
var fIRStorageUploadTask = null;
18821887

18831888
if (arg.localFile) {
1884-
if (typeof (arg.localFile) !== "object") {
1889+
if (typeof(arg.localFile) !== "object") {
18851890
reject("localFile argument must be a File object; use file-system module to create one");
18861891
return;
18871892
}
@@ -1900,7 +1905,7 @@ firebase.uploadFile = function (arg) {
19001905
if (fIRStorageUploadTask !== null) {
19011906
// Add a progress observer to an upload task
19021907
var fIRStorageHandle = fIRStorageUploadTask.observeStatusHandler(FIRStorageTaskStatusProgress, function (snapshot) {
1903-
if (!snapshot.error && typeof (arg.onProgress) === "function") {
1908+
if (!snapshot.error && typeof(arg.onProgress) === "function") {
19041909
arg.onProgress({
19051910
fractionCompleted: snapshot.progress.fractionCompleted,
19061911
percentageCompleted: Math.round(snapshot.progress.fractionCompleted * 100)
@@ -1939,7 +1944,7 @@ firebase.downloadFile = function (arg) {
19391944
var localFilePath;
19401945

19411946
if (arg.localFile) {
1942-
if (typeof (arg.localFile) !== "object") {
1947+
if (typeof(arg.localFile) !== "object") {
19431948
reject("localFile argument must be a File object; use file-system module to create one");
19441949
return;
19451950
}
@@ -2027,7 +2032,7 @@ firebase.subscribeToTopic = function (topicName) {
20272032
return new Promise(function (resolve, reject) {
20282033
try {
20292034

2030-
if (typeof (FIRMessaging) === "undefined") {
2035+
if (typeof(FIRMessaging) === "undefined") {
20312036
reject("Enable FIRMessaging in Podfile first");
20322037
return;
20332038
}
@@ -2048,7 +2053,7 @@ firebase.unsubscribeFromTopic = function (topicName) {
20482053
return new Promise(function (resolve, reject) {
20492054
try {
20502055

2051-
if (typeof (FIRMessaging) === "undefined") {
2056+
if (typeof(FIRMessaging) === "undefined") {
20522057
reject("Enable FIRMessaging in Podfile first");
20532058
return;
20542059
}
@@ -2068,7 +2073,7 @@ firebase.unsubscribeFromTopic = function (topicName) {
20682073
firebase.sendCrashLog = function (arg) {
20692074
return new Promise(function (resolve, reject) {
20702075
try {
2071-
if (typeof (FIRCrashLog) === "undefined") {
2076+
if (typeof(FIRCrashLog) === "undefined") {
20722077
reject("Make sure 'Firebase/Crash' is in the plugin's Podfile - and if it is there's currently a problem with this Pod which is outside out span of control :(");
20732078
return;
20742079
}
@@ -2096,7 +2101,7 @@ firebase.invites.sendInvitation = function (arg) {
20962101
return new Promise(function (resolve, reject) {
20972102
try {
20982103

2099-
if (typeof (FIRInvites) === "undefined") {
2104+
if (typeof(FIRInvites) === "undefined") {
21002105
reject("Make sure 'Firebase/Invites' is in the plugin's Podfile");
21012106
return;
21022107
}
@@ -2171,7 +2176,7 @@ firebase.invites.sendInvitation = function (arg) {
21712176
firebase.invites.getInvitation = function () {
21722177
return new Promise(function (resolve, reject) {
21732178
try {
2174-
if (typeof (FIRInvites) === "undefined") {
2179+
if (typeof(FIRInvites) === "undefined") {
21752180
reject("Make sure 'Firebase/Invites' is in the plugin's Podfile");
21762181
return;
21772182
}
@@ -2211,7 +2216,7 @@ var GADBannerViewDelegateImpl = (function (_super) {
22112216
GADBannerViewDelegateImpl.prototype.interstitialDidFailToReceiveAdWithError = function (ad, error) {
22122217
this._callback(ad, error);
22132218
};
2214-
if (typeof (GADInterstitialDelegate) !== "undefined") {
2219+
if (typeof(GADInterstitialDelegate) !== "undefined") {
22152220
GADBannerViewDelegateImpl.ObjCProtocols = [GADInterstitialDelegate];
22162221
}
22172222
return GADBannerViewDelegateImpl;
@@ -2235,7 +2240,7 @@ var GIDSignInDelegateImpl = (function (_super) {
22352240
GIDSignInDelegateImpl.prototype.signInDidSignInForUserWithError = function (signIn, user, error) {
22362241
this._callback(user, error);
22372242
};
2238-
if (typeof (GIDSignInDelegate) !== "undefined") {
2243+
if (typeof(GIDSignInDelegate) !== "undefined") {
22392244
GIDSignInDelegateImpl.ObjCProtocols = [GIDSignInDelegate];
22402245
}
22412246
return GIDSignInDelegateImpl;
@@ -2260,7 +2265,7 @@ var UNUserNotificationCenterDelegateImpl = (function (_super) {
22602265
UNUserNotificationCenterDelegateImpl.prototype.userNotificationCenterWillPresentNotificationWithCompletionHandler = function (unCenter, notification, completionHandler) {
22612266
this._callback(notification);
22622267
};
2263-
if (typeof (UNUserNotificationCenterDelegate) !== "undefined") {
2268+
if (typeof(UNUserNotificationCenterDelegate) !== "undefined") {
22642269
UNUserNotificationCenterDelegateImpl.ObjCProtocols = [UNUserNotificationCenterDelegate];
22652270
}
22662271
return UNUserNotificationCenterDelegateImpl;
@@ -2284,7 +2289,7 @@ var FIRInviteDelegateImpl = (function (_super) {
22842289
FIRInviteDelegateImpl.prototype.inviteFinishedWithInvitationsError = function (invitationIds, error) {
22852290
this._callback(invitationIds, error);
22862291
};
2287-
if (typeof (FIRInviteDelegate) !== "undefined") {
2292+
if (typeof(FIRInviteDelegate) !== "undefined") {
22882293
FIRInviteDelegateImpl.ObjCProtocols = [FIRInviteDelegate];
22892294
}
22902295
return FIRInviteDelegateImpl;
@@ -2323,7 +2328,7 @@ var FIRMessagingDelegateImpl = (function (_super) {
23232328
firebase._onTokenRefreshNotification(fcmToken);
23242329
};
23252330

2326-
if (typeof (FIRMessagingDelegate) !== "undefined") {
2331+
if (typeof(FIRMessagingDelegate) !== "undefined") {
23272332
FIRMessagingDelegateImpl.ObjCProtocols = [FIRMessagingDelegate];
23282333
}
23292334
return FIRMessagingDelegateImpl;

0 commit comments

Comments
 (0)