Skip to content

Commit

Permalink
Add type defs for missing API functions.
Browse files Browse the repository at this point in the history
Fix docs.
  • Loading branch information
dpa99c committed Feb 28, 2020
1 parent 52b4acb commit 88edc99
Show file tree
Hide file tree
Showing 3 changed files with 273 additions and 45 deletions.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -70,6 +70,7 @@ To help ensure this plugin is kept updated, new features are added and bugfixes
- [API](#api)
- [Notifications and data messages](#notifications-and-data-messages)
- [getToken](#gettoken)
- [getId](#getid)
- [onTokenRefresh](#ontokenrefresh)
- [getAPNSToken](#getapnstoken)
- [onApnsTokenReceived](#onapnstokenreceived)
Expand Down Expand Up @@ -1085,6 +1086,23 @@ FirebasePlugin.getToken(function(fcmToken) {
```
Note that token will be null if it has not been established yet.

#### getId
Get the app instance ID (an constant ID which persists as long as the app is not uninstalled/reinstalled).
Null if the ID has not been allocated yet by the Firebase SDK.

**Parameters**:
- {function} success - callback function which will be passed the {string} ID as an argument
- {function} error - callback function which will be passed a {string} error message as an argument

```javascript
FirebasePlugin.getId(function(appInstanceId) {
console.log(appInstanceId);
}, function(error) {
console.error(error);
});
```
Note that token will be null if it has not been established yet.

#### onTokenRefresh
Registers a handler to call when the FCM token changes.
This is the best way to get the token as soon as it has been allocated.
Expand Down
296 changes: 255 additions & 41 deletions types/index.d.ts
Expand Up @@ -12,19 +12,52 @@ interface IChannelOptions {
}

interface FirebasePlugin {
getToken(success: (value: string) => void, error: (err: string) => void): void
onTokenRefresh(success: (value: string) => void, error: (err: string) => void): void
getAPNSToken(success: (value: string) => void, error: (err: string) => void): void
onApnsTokenReceived(success: (value: string) => void, error: (err: string) => void): void
onMessageReceived(success: (value: object) => void, error: (err: string) => void): void
grantPermission(success: (value: boolean) => void, error: (err: string) => void): void
hasPermission(success: (value: boolean) => void, error: (err: string) => void): void
getId(
success: (value: string) => void,
error: (err: string) => void
): void
getToken(
success: (value: string) => void,
error: (err: string) => void
): void
onTokenRefresh(
success: (value: string) => void,
error: (err: string) => void): void
getAPNSToken(
success: (value: string) => void,
error: (err: string) => void
): void
onApnsTokenReceived(
success: (value: string) => void,
error: (err: string) => void
): void
onMessageReceived(
success: (value: object) => void,
error: (err: string) => void
): void
grantPermission(
success: (value: boolean) => void,
error: (err: string) => void
): void
hasPermission(
success: (value: boolean) => void,
error: (err: string) => void
): void
unregister(): void
setBadgeNumber(badgeNumber: number): void
getBadgeNumber(success: (badgeNumber: number) => void, error: (err: string) => void): void
setBadgeNumber(
badgeNumber: number
): void
getBadgeNumber(
success: (badgeNumber: number) => void,
error: (err: string) => void
): void
clearAllNotifications(): void
subscribe(topic: string): void
unsubscribe(topic: string): void
subscribe(
topic: string
): void
unsubscribe(
topic: string
): void
isAutoInitEnabled(
success: (enabled: boolean) => void,
error?: (err: string) => void
Expand All @@ -34,19 +67,50 @@ interface FirebasePlugin {
success?: () => void,
error?: (err: string) => void
): void
createChannel(channel: IChannelOptions, success: () => void, error: (err: string) => void): void
setDefaultChannel(channel: IChannelOptions, success: () => void, error: (err: string) => void): void
deleteChannel(channel: string, success: () => void, error: (err: string) => void): void
listChannels(success: (list: { id: string; name: string }[]) => void, error: (err: string) => void): void
setAnalyticsCollectionEnabled(setEnabled: boolean): void
logEvent(eventName: string, eventProperties: object): void
setScreenName(screenName: string): void
setUserId(userId: string): void
setUserProperty(userName: string, userValue: string): void
createChannel(
channel: IChannelOptions,
success: () => void,
error: (err: string) => void
): void
setDefaultChannel(
channel: IChannelOptions,
success: () => void,
error: (err: string) => void
): void
deleteChannel(
channel: string,
success: () => void,
error: (err: string) => void
): void
listChannels(
success: (list: { id: string; name: string }[]) => void,
error: (err: string) => void
): void
setAnalyticsCollectionEnabled(
setEnabled: boolean
): void
logEvent(
eventName: string,
eventProperties: object
): void
setScreenName(
screenName: string
): void
setUserId(
userId: string
): void
setUserProperty(
userName: string,
userValue: string
): void
setCrashlyticsCollectionEnabled(): void
setCrashlyticsUserId(userId: string): void
setCrashlyticsUserId(
userId: string
): void
sendCrash(): void
logMessage(message: string): void
logMessage(
message: string
): void
logError(
errorMessage: string,
stackTrace?: object,
Expand All @@ -60,29 +124,179 @@ interface FirebasePlugin {
timeOutDuration: number,
fakeVerificationCode?: string
): void
createUserWithEmailAndPassword(
email: string,
password: string,
success?: () => void,
error?: (err: string) => void
): void
signInUserWithEmailAndPassword(
email: string,
password: string,
success?: () => void,
error?: (err: string) => void
): void
authenticateUserWithGoogle(
clientId: string,
success?: () => void,
error?: (err: string) => void
): void
authenticateUserWithApple(
success?: () => void,
error?: (err: string) => void,
locale?: string,
): void
signInWithCredential(
verificationId: string,
code: string,
credential: object,
success?: () => void,
error?: (err: string) => void
): void
linkUserWithCredential(
verificationId: string,
code: string,
success?: () => void,
error?: (err: string) => void
): void
fetch(cacheExpirationSeconds: number, success: () => void, error: (err: string) => void): void
fetch(success: () => void, error: (err: string) => void): void
activateFetched(success: (activated: boolean) => void, error: (err: string) => void): void
getValue(key: string, success: (value: string) => void, error: (err: string) => void): void
getByteArray(key: string, success: (value: object) => void, error: (err: string) => void): void
getInfo(success: (info: object) => void, error: (err: string) => void): void
setConfigSettings(configSettings: object, success: (info: object) => void, error: (err: string) => void): void
setDefaults(defaultSettings: object, success: (info: object) => void, error: (err: string) => void): void
setPerformanceCollectionEnabled(setEnabled: boolean): void
startTrace(name: string, success: () => void, error: (err: string) => void): void
incrementCounter(name: string, counterName: string, success: () => void, error: (err: string) => void): void
stopTrace(name: string): void
credential: object,
success?: () => void,
error?: (err: string) => void
): void
reauthenticateWithCredential(
credential: object,
success?: () => void,
error?: (err: string) => void
): void
isUserSignedIn(
success: (isSignedIn: boolean) => void,
error?: (err: string) => void
): void
signOutUser(
success?: () => void,
error?: (err: string) => void
): void
getCurrentUser(
success: (user: object) => void,
error?: (err: string) => void
): void
updateUserProfile(
profile: {
name: string,
photoUri: string
},
success?: () => void,
error?: (err: string) => void
): void
updateUserEmail(
email: string,
success?: () => void,
error?: (err: string) => void
): void
sendUserEmailVerification(
success?: () => void,
error?: (err: string) => void
): void
updateUserPassword(
password: string,
success?: () => void,
error?: (err: string) => void
): void
sendUserPasswordResetEmail(
email: string,
success?: () => void,
error?: (err: string) => void
): void
deleteUser(
success?: () => void,
error?: (err: string) => void
): void
registerAuthStateChangeListener(
fn: (userSignedIn: boolean) => void,
): void
fetch(
cacheExpirationSeconds: number,
success: () => void,
error: (err: string) => void
): void
fetch(
success: () => void,
error: (err: string) => void
): void
activateFetched(
success: (activated: boolean) => void,
error: (err: string) => void
): void
getValue(
key: string,
success: (value: string) => void,
error: (err: string) => void
): void
getByteArray(
key: string,
success: (value: object) => void,
error: (err: string) => void
): void
getInfo(
success: (info: object) => void,
error: (err: string) => void
): void
setConfigSettings(
configSettings: object,
success: (info: object) => void,
error: (err: string) => void
): void
setDefaults(
defaultSettings: object,
success: (info: object) => void,
error: (err: string) => void
): void
setPerformanceCollectionEnabled(
setEnabled: boolean
): void
startTrace(
name: string,
success: () => void,
error: (err: string) => void
): void
incrementCounter(
name: string,
counterName: string,
success: () => void,
error: (err: string) => void
): void
stopTrace(
name: string
): void
addDocumentToFirestoreCollection(
document: object,
collection: string,
success: () => void,
error: (err: string) => void
): void
setDocumentInFirestoreCollection(
documentId: string,
document: object,
collection: string,
success: () => void,
error: (err: string) => void
): void
updateDocumentInFirestoreCollection(
documentId: string,
document: object,
collection: string,
success: () => void,
error: (err: string) => void
): void
deleteDocumentFromFirestoreCollection(
documentId: string,
collection: string,
success: () => void,
error: (err: string) => void
): void
fetchDocumentInFirestoreCollection(
documentId: string,
collection: string,
success: (document: object) => void,
error: (err: string) => void
): void
fetchFirestoreCollection(
collection: string,
success: (collection: object) => void,
error: (err: string) => void
): void
}
declare var FirebasePlugin: FirebasePlugin;
4 changes: 0 additions & 4 deletions www/firebase.js
Expand Up @@ -28,10 +28,6 @@ exports._onAuthStateChange = function(userSignedIn){
* Public API
**************/

exports.getVerificationID = function (number, success, error) {
exec(success, error, "FirebasePlugin", "getVerificationID", [number]);
};

// Notifications
exports.getId = function (success, error) {
exec(success, error, "FirebasePlugin", "getId", []);
Expand Down

0 comments on commit 88edc99

Please sign in to comment.