Merge branch 'master' of https://github.com/invertase/react-native-firebase into bridge-detox

This commit is contained in:
Salakar 2018-03-23 22:24:49 +00:00
commit e0d62f3945
23 changed files with 447 additions and 612 deletions

View File

@ -35,27 +35,27 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a
> '**?**' indicates partial support
| Firebase Features | v1.x.x | v2.x.x | v3.x.x | v3.1.x | v3.2.x | Web SDK |
| -------------------------- | :----: | :----: | :----: | :----: | :----: | :-----: |
| **AdMob** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
| **Analytics**             | ✅ | ✅ | ✅ | ✅ | ✅ | |
| **App Indexing**           | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| **Authentication** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| _-- Phone Auth_ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
| **Core** | ❌ | **?** | ✅ | ✅ | ✅ | ✅ |
| _-- Multiple Apps_ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
| **Cloud Firestore** | ❌ | ❌ | ✅ | ✅ | ✅ | **?** |
| **Cloud Messaging (FCM)** | ✅ | ✅ | ✅ | ✅ | ✅ | **?** |
| **Crashlytics**           | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
| **Crash Reporting** | ✅ | ✅ | ✅ | ✅ | ✅ | |
| **Dynamic Links** | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
| **Invites** | ❌ | ❌ | ❌ | **?** | **?** | ❌ |
| **Performance Monitoring** | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| **Realtime Database** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| _-- Offline Persistence_ | ✅ | ✅ | ✅ | ✅ | ✅ | **?** |
| _-- Transactions_ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| **Remote Config** | ✅ | ✅ | ✅ | ✅ | ✅ | |
| **Storage** | ✅ | ✅ | ✅ | ✅ | ✅ | **?** |
| Firebase Features | v2.2.x | v3.3.x | v4.0.x | Web SDK |
| -------------------------- | :----: | :----: | :----: | :-----: |
| **AdMob** | ✅ | ✅ | ✅ | ❌ |
| **Analytics**             | ✅ | ✅ | ✅ | ❌ |
| **App Indexing**           | ❌ | ❌ | ❌ | ❌ |
| **Authentication** | ✅ | ✅ | ✅ | ✅ |
| _-- Phone Auth_ | ❌ | ✅ | ✅ | ❌ |
| **Core** | **?** | ✅ | ✅ | ✅ |
| _-- Multiple Apps_ | ❌ | ✅ | ✅ | ✅ |
| **Cloud Firestore** | ❌ | ✅ | ✅ | **?** |
| **Cloud Messaging (FCM)** | **?** | **?** | ✅ | ❌ |
| **Crashlytics**           | ❌ | ✅ | ✅ | ❌ |
| **Crash Reporting** | ✅ | ✅ | ✅ | ❌ |
| **Dynamic Links** | ❌ | ✅ | ✅ | ❌ |
| **Invites** | ❌ | ❌ | ✅ | ❌ |
| **Instance ID**          | ❌ | ❌ | **?** | ❌ |
| **Performance Monitoring** | ✅ | ✅ | ✅ | ❌ |
| **Realtime Database** | ✅ | ✅ | ✅ | ✅ |
| _-- Offline Persistence_ | ✅ | ✅ | ✅ | **?** |
| **Remote Config** | ✅ | ✅ | ✅ | ❌ |
| **Storage** | ✅ | ✅ | ✅ | **?** |
---
@ -63,11 +63,11 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a
> The table below shows the supported versions of React Native and the Firebase SDKs for different versions of `react-native-firebase`
| | 1.X.X | 2.0.X | 2.1.X / 2.2.X | 3.0.X | 3.1.X | 3.2.X |
| -------------------- | ----------- | ----------- | ------------- | -------- | ----------- | -------- |
| React Native | 0.36 - 0.39 | 0.40 - 0.46 | 0.47 + | 0.48 + | 0.48 - 0.49 | 0.50 + |
| Firebase Android SDK | 10.2.0 + | 11.0.0 + | 11.0.0 + | 11.4.2 + | 11.6.0 + | 11.6.2 + |
| Firebase iOS SDK | 3.15.0 + | 4.0.0 + | 4.0.0 + | 4.3.0 + | 4.5.0 + | 4.7.0 + |
| | 2.2.x | 3.3.x | 4.0.x |
|------------------------|----------|----------|----------|
| React Native | 0.47 + | 0.50 + | 0.52 + |
| Firebase Android SDK | 11.0.0 + | 11.8.0 + | 12.0.0 + |
| Firebase iOS SDK | 4.0.0 + | 4.7.0 + | 4.11.0 + |
---

View File

@ -1,5 +1,5 @@
buildscript {
ext.firebaseVersion = '11.8.0'
ext.firebaseVersion = '12.0.0'
repositories {
jcenter()
mavenLocal()

View File

@ -92,6 +92,11 @@ public class RNFirebaseAdMobRewardedVideo implements RewardedVideoAdListener {
sendEvent("onAdClosed", null);
}
@Override
public void onRewardedVideoCompleted() {
sendEvent("onAdCompleted", null);
}
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
WritableMap payload = RNFirebaseAdMobUtils.errorCodeToMap(errorCode);

266
lib/index.d.ts vendored
View File

@ -30,8 +30,11 @@ declare module "react-native-firebase" {
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
};
firestore: FirebaseModuleAndStatics<RNFirebase.firestore.Firestore, RNFirebase.firestore.FirestoreStatics>;
iid: FirebaseModuleAndStatics<RNFirebase.iid.InstanceId>
// invites: FirebaseModuleAndStatics<RNFirebase.invites.Invites>
links: FirebaseModuleAndStatics<RNFirebase.links.Links>;
messaging: FirebaseModuleAndStatics<RNFirebase.messaging.Messaging>;
notifications: FirebaseModuleAndStatics<RNFirebase.notifications.Notifications>;
// perf: FirebaseModuleAndStatics<RNFirebase.perf.Perf>;
storage: FirebaseModuleAndStatics<RNFirebase.storage.Storage>;
// utils: FirebaseModuleAndStatics<RNFirebase.utils.Utils>;
@ -66,8 +69,11 @@ declare module "react-native-firebase" {
crashlytics(): RNFirebase.crashlytics.Crashlytics,
};
firestore(): RNFirebase.firestore.Firestore;
iid(): RNFirebase.iid.InstanceId;
// invites(): RNFirebase.invites.Invites;
links(): RNFirebase.links.Links;
messaging(): RNFirebase.messaging.Messaging;
notifications(): RNFirebase.notifications.Notifications;
// perf(): RNFirebase.perf.Performance;
storage(): RNFirebase.storage.Storage;
// utils(): RNFirebase.utils.Utils;
@ -875,33 +881,17 @@ declare module "react-native-firebase" {
namespace messaging {
interface Messaging {
/**
* Subscribes the device to a topic.
*/
subscribeToTopic(topic: string): void
/**
* Unsubscribes the device from a topic.
*/
unsubscribeFromTopic(topic: string): void
/**
* When the application has been opened from a notification
* getInitialNotification is called and the notification payload is returned.
* Use onMessage for notifications when the app is running.
*/
getInitialNotification(): Promise<any>
/**
* Returns the devices FCM token.
* This token can be used in the Firebase console to send messages to directly.
*/
getToken(forceRefresh?: Boolean): Promise<string>
getToken(): Promise<string>
/**
* Reset Instance ID and revokes all tokens.
* On a new message,
* the payload object is passed to the listener callback.
* This method is only triggered when the app is running.
*/
deleteInstanceId(): Promise<any>
onMessage(listener: (message: any) => any): () => any
/**
* On the event a devices FCM token is refreshed by Google,
@ -910,84 +900,111 @@ declare module "react-native-firebase" {
onTokenRefresh(listener: (token: string) => any): () => any
/**
* On a new message,
* the payload object is passed to the listener callback.
* This method is only triggered when the app is running.
* Use getInitialNotification for notifications which cause the app to open.
*/
onMessage(listener: (message: any) => any): () => any
/**
* Create a local notification from the device itself.
*/
createLocalNotification(notification: any): any
/**
* Schedule a local notification to be shown on the device.
*/
scheduleLocalNotification(notification: any): any
/**
* Returns an array of all currently scheduled notifications.
* ```
* firebase.messaging().getScheduledLocalNotifications()
* .then((notifications) => {
* console.log('Current scheduled notifications: ', notifications);
* });
* ```
*/
getScheduledLocalNotifications(): Promise<any[]>
/**
* Cancels a location notification by ID,
* or all notifications by *.
*/
cancelLocalNotification(id: string): void
/**
* Removes all delivered notifications from device by ID,
* or all notifications by *.
*/
removeDeliveredNotification(id: string): void
/**
* IOS
* Requests app notification permissions in an Alert dialog.
*/
requestPermissions(): Promise<{ granted: boolean }>;
requestPermission(): Promise<boolean>;
/**
* Sets the badge number on the iOS app icon.
* Checks if the app has notification permissions.
*/
setBadgeNumber(value: number): void
hasPermission(): Promise<boolean>;
/**
* Send an upstream message
*/
sendMessage(remoteMessage: RemoteMessage): Promise<void>
/**
* Subscribes the device to a topic.
*/
subscribeToTopic(topic: string): void
/**
* Unsubscribes the device from a topic.
*/
unsubscribeFromTopic(topic: string): void
}
interface RemoteMessage {
collapseKey?: string
data: Object
from?: string
messageId?: string
messageType: string
sentTime?: number
to?: string
ttl?: number
setCollapseKey(collapseKey: string): RemoteMessage
setData(data: Object): RemoteMessage
setMessageId(messageId: string): RemoteMessage
setMessageType(messageType: string): RemoteMessage
setTo(to: string): RemoteMessage
setTtl(ttl: number): RemoteMessage
}
}
namespace iid {
interface InstanceId {
delete(): Promise<void>
get(): Promise<string>
}
}
namespace notifications {
interface AndroidNotifications {
createChannel(channel: any): Promise<void>
createChannelGroup(channelGroup: any): Promise<void>
createChannelGroups(channelGroups: any[]): Promise<void>
createChannels(channels: any[]): Promise<void>
}
interface Notifications {
android: AndroidNotifications
/**
* Cancels all notifications
*/
cancelAllNotifications(): void
/**
* Cancels a notification by ID
*/
cancelNotification(notificationId: string): void
displayNotification(notification: any): Promise<void>
/**
* Returns the current badge number on the app icon.
*/
getBadgeNumber(): Promise<number>
getBadge(): Promise<number>
getInitialNotification(): Promise<any>
getScheduledNotifications(): Promise<any[]>
onNotification(listener: (notification: any) => any): () => any
onNotificationDisplayed(listener: (notification: any) => any): () => any
onNotificationOpened(listener: (notificationOpen: any) => any): () => any
removeAllDeliveredNotifications(): void
removeDeliveredNotification(notificationId: string): void
/**
* Send an upstream message
* @param senderId
* @param payload
* Schedule a local notification to be shown on the device.
*/
sendMessage(senderId: string, payload: RemoteMessage): any
scheduleNotification(notification: any, schedule: any): any
NOTIFICATION_TYPE: Object
REMOTE_NOTIFICATION_RESULT: Object
WILL_PRESENT_RESULT: Object
EVENT_TYPE: Object
}
interface RemoteMessage {
id: string,
type: string,
ttl?: number,
sender: string,
collapseKey?: string,
data: Object,
/**
* Sets the badge number on the iOS app icon.
*/
setBadge(badge: number): void
}
}
namespace crash {
interface Crash {
@ -1058,9 +1075,9 @@ declare module "react-native-firebase" {
namespace links {
interface Links {
/** Creates a standard dynamic link. */
createDynamicLink(parameters: LinkConfiguration): Promise<string>;
createDynamicLink(dynamicLink: DynamicLink): Promise<string>;
/** Creates a short dynamic link. */
createShortDynamicLink(parameters: LinkConfiguration): Promise<string>;
createShortDynamicLink(type: 'SHORT' | 'UNGUESSABLE'): Promise<string>;
/**
* Returns the URL that the app has been launched from. If the app was
* not launched from a URL the return value will be null.
@ -1077,36 +1094,53 @@ declare module "react-native-firebase" {
onLink(listener: (url: string) => void): () => void;
}
/**
* Configuration when creating a Dynamic Link (standard or short). For
* more information about each parameter, see the official Firebase docs:
* https://firebase.google.com/docs/reference/dynamic-links/link-shortener
*/
interface LinkConfiguration {
link: string,
dynamicLinkDomain: string,
androidInfo?: {
androidLink?: string,
androidPackageName: string,
androidFallbackLink?: string,
androidMinPackageVersionCode?: string,
},
iosInfo?: {
iosBundleId: string,
iosAppStoreId?: string,
iosFallbackLink?: string,
iosCustomScheme?: string,
iosIpadBundleId?: string,
iosIpadFallbackLink?: string,
},
socialMetaTagInfo?: {
socialTitle: string,
socialImageLink: string,
socialDescription: string,
},
suffix?: {
option: 'SHORT' | 'UNGUESSABLE',
},
interface DynamicLink {
analytics: AnalyticsParameters
android: AndroidParameters
ios: IOSParameters
itunes: ITunesParameters
navigation: NavigationParameters
social: SocialParameters
}
interface AnalyticsParameters {
setCampaign(campaign: string): DynamicLink
setContent(content: string): DynamicLink
setMedium(medium: string): DynamicLink
setSource(source: string): DynamicLink
setTerm(term: string): DynamicLink
}
interface AndroidParameters {
setFallbackUrl(fallbackUrl: string): DynamicLink
setMinimumVersion(minimumVersion: number): DynamicLink
setPackageName(packageName: string): DynamicLink
}
interface IOSParameters {
setAppStoreId(appStoreId: string): DynamicLink
setBundleId(bundleId: string): DynamicLink
setCustomScheme(customScheme: string): DynamicLink
setFallbackUrl(fallbackUrl: string): DynamicLink
setIPadBundleId(iPadBundleId: string): DynamicLink
setIPadFallbackUrl(iPadFallbackUrl: string): DynamicLink
setMinimumVersion(minimumVersion: string): DynamicLink
}
interface ITunesParameters {
setAffiliateToken(affiliateToken: string): DynamicLink
setCampaignToken(campaignToken: string): DynamicLink
setProviderToken(providerToken: string): DynamicLink
}
interface NavigationParameters {
setForcedRedirectEnabled(forcedRedirectEnabled: boolean): DynamicLink
}
interface SocialParameters {
setDescriptionText(descriptionText: string): DynamicLink
setImageUrl(imageUrl: string): DynamicLink
setTitle(title: string): DynamicLink
}
}

View File

@ -18,7 +18,7 @@ import Crashlytics, {
} from '../fabric/crashlytics';
import Database, { NAMESPACE as DatabaseNamespace } from '../database';
import Firestore, { NAMESPACE as FirestoreNamespace } from '../firestore';
import InstanceId, { NAMESPACE as InstanceIdNamespace } from '../instanceid';
import InstanceId, { NAMESPACE as InstanceIdNamespace } from '../iid';
import Invites, { NAMESPACE as InvitesNamespace } from '../invites';
import Links, { NAMESPACE as LinksNamespace } from '../links';
import Messaging, { NAMESPACE as MessagingNamespace } from '../messaging';
@ -49,7 +49,7 @@ export default class App {
crashlytics: () => Crashlytics,
};
firestore: () => Firestore;
instanceid: () => InstanceId;
iid: () => InstanceId;
invites: () => Invites;
links: () => Links;
messaging: () => Messaging;
@ -91,7 +91,7 @@ export default class App {
crashlytics: APPS.appModule(this, CrashlyticsNamespace, Crashlytics),
};
this.firestore = APPS.appModule(this, FirestoreNamespace, Firestore);
this.instanceid = APPS.appModule(this, InstanceIdNamespace, InstanceId);
this.iid = APPS.appModule(this, InstanceIdNamespace, InstanceId);
this.invites = APPS.appModule(this, InvitesNamespace, Invites);
this.links = APPS.appModule(this, LinksNamespace, Links);
this.messaging = APPS.appModule(this, MessagingNamespace, Messaging);

View File

@ -41,7 +41,7 @@ import {
import {
statics as InstanceIdStatics,
MODULE_NAME as InstanceIdModuleName,
} from '../instanceid';
} from '../iid';
import {
statics as InvitesStatics,
MODULE_NAME as InvitesModuleName,
@ -102,7 +102,7 @@ class Firebase {
database: DatabaseModule;
fabric: FabricModule;
firestore: FirestoreModule;
instanceid: InstanceIdModule;
iid: InstanceIdModule;
invites: InvitesModule;
links: LinksModule;
messaging: MessagingModule;
@ -148,8 +148,8 @@ class Firebase {
FirestoreStatics,
FirestoreModuleName
);
this.instanceid = APPS.moduleAndStatics(
'instanceid',
this.iid = APPS.moduleAndStatics(
'iid',
InstanceIdStatics,
InstanceIdModuleName
);

View File

@ -8,7 +8,7 @@ import { getNativeModule } from '../../utils/native';
import type App from '../core/app';
export const MODULE_NAME = 'RNFirebaseInstanceId';
export const NAMESPACE = 'instanceid';
export const NAMESPACE = 'iid';
export default class InstanceId extends ModuleBase {
constructor(app: App) {

View File

@ -41,9 +41,9 @@ export default class Invites extends ModuleBase {
/**
* Returns the invitation that triggered application open
* @returns {Promise.<Object>}
* @returns {Promise.<InvitationOpen>}
*/
getInitialInvitation(): Promise<string> {
getInitialInvitation(): Promise<?InvitationOpen> {
return getNativeModule(this).getInitialInvitation();
}
@ -65,11 +65,17 @@ export default class Invites extends ModuleBase {
sendInvitation(invitation: Invitation): Promise<string[]> {
if (!(invitation instanceof Invitation)) {
throw new Error(
`Invites:sendInvitation expects an 'Invitation' but got type ${typeof invitation}`
return Promise.reject(
new Error(
`Invites:sendInvitation expects an 'Invitation' but got type ${typeof invitation}`
)
);
}
return getNativeModule(this).sendInvitation(invitation.build());
try {
return getNativeModule(this).sendInvitation(invitation.build());
} catch (error) {
return Promise.reject(error);
}
}
}

View File

@ -6,7 +6,7 @@ import type DynamicLink from './DynamicLink';
import type { NativeNavigationParameters } from './types';
export default class NavigationParameters {
_forcedRedirectEnabled: string | void;
_forcedRedirectEnabled: boolean | void;
_link: DynamicLink;
constructor(link: DynamicLink) {
@ -18,7 +18,7 @@ export default class NavigationParameters {
* @param forcedRedirectEnabled
* @returns {DynamicLink}
*/
setForcedRedirectEnabled(forcedRedirectEnabled: string): DynamicLink {
setForcedRedirectEnabled(forcedRedirectEnabled: boolean): DynamicLink {
this._forcedRedirectEnabled = forcedRedirectEnabled;
return this._link;
}

View File

@ -45,11 +45,17 @@ export default class Links extends ModuleBase {
*/
createDynamicLink(link: DynamicLink): Promise<string> {
if (!(link instanceof DynamicLink)) {
throw new Error(
`Links:createDynamicLink expects a 'DynamicLink' but got type ${typeof link}`
return Promise.reject(
new Error(
`Links:createDynamicLink expects a 'DynamicLink' but got type ${typeof link}`
)
);
}
return getNativeModule(this).createDynamicLink(link.build());
try {
return getNativeModule(this).createDynamicLink(link.build());
} catch (error) {
return Promise.reject(error);
}
}
/**
@ -62,18 +68,24 @@ export default class Links extends ModuleBase {
type?: 'SHORT' | 'UNGUESSABLE'
): Promise<String> {
if (!(link instanceof DynamicLink)) {
throw new Error(
`Links:createShortDynamicLink expects a 'DynamicLink' but got type ${typeof link}`
return Promise.reject(
new Error(
`Links:createShortDynamicLink expects a 'DynamicLink' but got type ${typeof link}`
)
);
}
return getNativeModule(this).createShortDynamicLink(link.build(), type);
try {
return getNativeModule(this).createShortDynamicLink(link.build(), type);
} catch (error) {
return Promise.reject(error);
}
}
/**
* Returns the link that triggered application open
* @returns {Promise.<String>}
*/
getInitialLink(): Promise<string> {
getInitialLink(): Promise<?string> {
return getNativeModule(this).getInitialLink();
}
@ -94,4 +106,6 @@ export default class Links extends ModuleBase {
}
}
export const statics = {};
export const statics = {
DynamicLink,
};

View File

@ -32,7 +32,7 @@ export type NativeITunesParameters = {|
|};
export type NativeNavigationParameters = {|
forcedRedirectEnabled?: string,
forcedRedirectEnabled?: boolean,
|};
export type NativeSocialParameters = {|

View File

@ -129,11 +129,17 @@ export default class Messaging extends ModuleBase {
sendMessage(remoteMessage: RemoteMessage): Promise<void> {
if (!(remoteMessage instanceof RemoteMessage)) {
throw new Error(
`Messaging:sendMessage expects a 'RemoteMessage' but got type ${typeof remoteMessage}`
return Promise.reject(
new Error(
`Messaging:sendMessage expects a 'RemoteMessage' but got type ${typeof remoteMessage}`
)
);
}
return getNativeModule(this).sendMessage(remoteMessage.build());
try {
return getNativeModule(this).sendMessage(remoteMessage.build());
} catch (error) {
return Promise.reject(error);
}
}
subscribeToTopic(topic: string): void {

View File

@ -152,11 +152,17 @@ export default class Notifications extends ModuleBase {
*/
displayNotification(notification: Notification): Promise<void> {
if (!(notification instanceof Notification)) {
throw new Error(
`Notifications:displayNotification expects a 'Notification' but got type ${typeof notification}`
return Promise.reject(
new Error(
`Notifications:displayNotification expects a 'Notification' but got type ${typeof notification}`
)
);
}
return getNativeModule(this).displayNotification(notification.build());
try {
return getNativeModule(this).displayNotification(notification.build());
} catch (error) {
return Promise.reject(error);
}
}
getBadge(): Promise<number> {
@ -285,13 +291,19 @@ export default class Notifications extends ModuleBase {
schedule: Schedule
): Promise<void> {
if (!(notification instanceof Notification)) {
throw new Error(
`Notifications:scheduleNotification expects a 'Notification' but got type ${typeof notification}`
return Promise.reject(
new Error(
`Notifications:scheduleNotification expects a 'Notification' but got type ${typeof notification}`
)
);
}
const nativeNotification = notification.build();
nativeNotification.schedule = schedule;
return getNativeModule(this).scheduleNotification(nativeNotification);
try {
const nativeNotification = notification.build();
nativeNotification.schedule = schedule;
return getNativeModule(this).scheduleNotification(nativeNotification);
} catch (error) {
return Promise.reject(error);
}
}
setBadge(badge: number): void {

View File

@ -15,8 +15,8 @@ import type Database from '../modules/database';
import { typeof statics as DatabaseStatics } from '../modules/database';
import type Firestore from '../modules/firestore';
import { typeof statics as FirestoreStatics } from '../modules/firestore';
import type InstanceId from '../modules/instanceid';
import { typeof statics as InstanceIdStatics } from '../modules/instanceid';
import type InstanceId from '../modules/iid';
import { typeof statics as InstanceIdStatics } from '../modules/iid';
import type Invites from '../modules/invites';
import { typeof statics as InvitesStatics } from '../modules/invites';
import type Links from '../modules/links';
@ -81,7 +81,7 @@ export type FirebaseNamespace =
| 'crashlytics'
| 'database'
| 'firestore'
| 'instanceid'
| 'iid'
| 'invites'
| 'links'
| 'messaging'

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "react-native-firebase",
"version": "4.0.0-alpha.1",
"version": "4.0.0-rc.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "react-native-firebase",
"version": "4.0.0-alpha.1",
"version": "4.0.0-rc.2",
"author": "Invertase <contact@invertase.io> (http://invertase.io)",
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Messaging (FCM), Remote Config, Storage and Performance.",
"main": "dist/index.js",

View File

@ -27,8 +27,8 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
applicationId "com.reactnativefirebasedemo"
@ -70,7 +70,7 @@ android {
}
}
project.ext.firebaseVersion = '11.8.0'
project.ext.firebaseVersion = '12.0.0'
dependencies {
compile project(':react-native-vector-icons')
@ -93,7 +93,7 @@ dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
compile "com.android.support:appcompat-v7:26.0.2"
compile "com.android.support:appcompat-v7:27.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

View File

@ -29,8 +29,8 @@ allprojects {
subprojects {
ext {
compileSdk = 26
buildTools = "26.0.2"
compileSdk = 27
buildTools = "27.0.1"
minSdk = 16
targetSdk = 26
}

View File

@ -4,37 +4,37 @@
<dict>
<key>AD_UNIT_ID_FOR_BANNER_TEST</key>
<string>ca-app-pub-3940256099942544/2934735716</string>
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
<string>ca-app-pub-3940256099942544/4411468910</string>
<key>CLIENT_ID</key>
<string>17067372085-siujfe334vool17t2mtrmjrsgl81nhd9.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.17067372085-siujfe334vool17t2mtrmjrsgl81nhd9</string>
<key>API_KEY</key>
<string>AIzaSyC8ZEruBCvS_6woF8_l07ILy1eXaD6J4vQ</string>
<key>GCM_SENDER_ID</key>
<string>17067372085</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.invertase.RNFirebaseTests</string>
<key>PROJECT_ID</key>
<string>rnfirebase</string>
<key>STORAGE_BUCKET</key>
<string>rnfirebase.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<true></true>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<false></false>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:17067372085:ios:d9ef660bd02cc2f1</string>
<key>DATABASE_URL</key>
<string>https://rnfirebase-5579a.firebaseio.com</string>
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
<string>ca-app-pub-3940256099942544/4411468910</string>
<key>CLIENT_ID</key>
<string>305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib</string>
<key>API_KEY</key>
<string>AIzaSyAcdVLG5dRzA1ck_fa_xd4Z0cY7cga7S5A</string>
<key>GCM_SENDER_ID</key>
<string>305229645282</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.invertase.ReactNativeFirebaseDemo</string>
<key>PROJECT_ID</key>
<string>rnfirebase-b9ad4</string>
<key>STORAGE_BUCKET</key>
<string>rnfirebase-b9ad4.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<true/>
<key>IS_ANALYTICS_ENABLED</key>
<false/>
<key>IS_APPINVITE_ENABLED</key>
<false/>
<key>IS_GCM_ENABLED</key>
<true/>
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>1:305229645282:ios:7b45748cb1117d2d</string>
<key>DATABASE_URL</key>
<string>https://rnfirebase-b9ad4.firebaseio.com</string>
</dict>
</plist>

View File

@ -7,41 +7,41 @@ PODS:
- BoringSSL/Interface (10.0)
- Crashlytics (3.10.1):
- Fabric (~> 1.7.5)
- Fabric (1.7.5)
- Firebase/AdMob (4.10.0):
- Fabric (1.7.6)
- Firebase/AdMob (4.11.0):
- Firebase/Core
- Google-Mobile-Ads-SDK (= 7.29.0)
- Firebase/Auth (4.10.0):
- Firebase/Auth (4.11.0):
- Firebase/Core
- FirebaseAuth (= 4.4.4)
- Firebase/Core (4.10.0):
- FirebaseAuth (= 4.5.0)
- Firebase/Core (4.11.0):
- FirebaseAnalytics (= 4.1.0)
- FirebaseCore (= 4.0.16)
- Firebase/Crash (4.10.0):
- FirebaseCore (= 4.0.18)
- Firebase/Crash (4.11.0):
- Firebase/Core
- FirebaseCrash (= 2.0.2)
- Firebase/Database (4.10.0):
- Firebase/Database (4.11.0):
- Firebase/Core
- FirebaseDatabase (= 4.1.5)
- Firebase/DynamicLinks (4.10.0):
- Firebase/DynamicLinks (4.11.0):
- Firebase/Core
- FirebaseDynamicLinks (= 2.3.2)
- Firebase/Firestore (4.10.0):
- Firebase/Firestore (4.11.0):
- Firebase/Core
- FirebaseFirestore (= 0.10.2)
- Firebase/Invites (4.10.0):
- FirebaseFirestore (= 0.10.4)
- Firebase/Invites (4.11.0):
- Firebase/Core
- FirebaseInvites (= 2.0.2)
- Firebase/Messaging (4.10.0):
- Firebase/Messaging (4.11.0):
- Firebase/Core
- FirebaseMessaging (= 2.1.1)
- Firebase/Performance (4.10.0):
- Firebase/Performance (4.11.0):
- Firebase/Core
- FirebasePerformance (= 1.1.2)
- Firebase/RemoteConfig (4.10.0):
- Firebase/RemoteConfig (4.11.0):
- Firebase/Core
- FirebaseRemoteConfig (= 2.1.2)
- Firebase/Storage (4.10.0):
- Firebase/Storage (4.11.0):
- Firebase/Core
- FirebaseStorage (= 2.1.3)
- FirebaseABTesting (1.0.0):
@ -52,11 +52,11 @@ PODS:
- FirebaseInstanceID (~> 2.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- nanopb (~> 0.3)
- FirebaseAuth (4.4.4):
- FirebaseAuth (4.5.0):
- FirebaseAnalytics (~> 4.1)
- GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseCore (4.0.16):
- FirebaseCore (4.0.18):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseCrash (2.0.2):
- FirebaseAnalytics (~> 4.0)
@ -70,13 +70,13 @@ PODS:
- leveldb-library (~> 1.18)
- FirebaseDynamicLinks (2.3.2):
- FirebaseAnalytics (~> 4.0)
- FirebaseFirestore (0.10.2):
- FirebaseFirestore (0.10.4):
- FirebaseAnalytics (~> 4.1)
- FirebaseCore (~> 4.0)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.5)
- FirebaseInstanceID (2.0.9):
- FirebaseInstanceID (2.0.10):
- FirebaseCore (~> 4.0)
- FirebaseInvites (2.0.2):
- FirebaseAnalytics (~> 4.0)
@ -244,17 +244,17 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
BoringSSL: 32764dbaf5f5888cf51fbaa172a010126b41bcd4
Crashlytics: aee1a064cbbf99b32efa3f056a5f458d846bc8ff
Fabric: ae7146a5f505ea370a1e44820b4b1dc8890e2890
Firebase: c98c8b1fbcbdccd82539a36c2b17a9b1bb0ee798
Fabric: f8d42c893bb187326a7968b62abe55c36a987a46
Firebase: cc13dfab1038c8b45d7903e01fc690451d6d0b24
FirebaseABTesting: d07d0ee833b842d5153549e4c7e2e2cb1c23a3f9
FirebaseAnalytics: 3dfae28d4a5e06f86c4fae830efc2ad3fadb19bc
FirebaseAuth: d040bb7a9db6dfc29d0e7ec82d48be51352b2581
FirebaseCore: eb9e1a56733ff1094ecf3e28af9069c344b25239
FirebaseAuth: 147bf340a0706b44ca1753d6b41ebafd9687cfe6
FirebaseCore: b981f47e5254cbcfdeb483355300d743f6fcab2c
FirebaseCrash: cded0fc566c03651aea606a101bc156085f333ca
FirebaseDatabase: 5f0bc6134c5c237cf55f9e1249d406770a75eafd
FirebaseDynamicLinks: 38b68641d24e78d0277a9205d988ce22875d5a25
FirebaseFirestore: 9423ca756bbf77bfa3cd02fafc8027ae79da625a
FirebaseInstanceID: d2058a35e9bebda1b6dd42486b84917bde552a9d
FirebaseFirestore: 796df79c29cf8ecf806564f4d347665bdafa6ef0
FirebaseInstanceID: 8d20d890d65c917f9f7d9950b6e10a760ad34321
FirebaseInvites: ae15e0636f9eb42bdf5c1ef4c8f7bd4a88f9878b
FirebaseMessaging: db0e01c52ef7e1f42846431273558107d084ede4
FirebasePerformance: 96c831a9eaf8d2ddf8bb37a4a6f6dd1b4bfe929f

View File

@ -118,7 +118,7 @@ const invitations = async () => {
}
};
invitations();
// invitations();
const config = {
apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E',

View File

@ -24,30 +24,25 @@ function linksTests({ describe, it, firebase, tryCatch }) {
const socialImageLink = 'test.imageUrl.com';
it('create long dynamic link with all supported parameters', async () => {
const data = {
const dynamicLink = new firebase.native.links.DynamicLink(
link,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
androidFallbackLink,
androidMinPackageVersionCode,
},
iosInfo: {
iosBundleId,
iosFallbackLink,
iosCustomScheme,
iosIpadFallbackLink,
iosIpadBundleId,
iosAppStoreId,
},
socialMetaTagInfo: {
socialTitle,
socialDescription,
socialImageLink,
},
};
dynamicLinkDomain
);
dynamicLink.android
.setPackageName(androidPackageName)
.android.setFallbackUrl(androidFallbackLink)
.android.setMinimumVersion(androidMinPackageVersionCode)
.ios.setBundleId(iosBundleId)
.ios.setFallbackUrl(iosFallbackLink)
.ios.setCustomScheme(iosCustomScheme)
.ios.setIPadFallbackUrl(iosIpadFallbackLink)
.ios.setIPadBundleId(iosIpadBundleId)
.ios.setAppStoreId(iosAppStoreId)
.social.setTitle(socialTitle)
.social.setDescriptionText(socialDescription)
.social.setImageUrl(socialImageLink);
const result = await links.createDynamicLink(data);
const result = await links.createDynamicLink(dynamicLink);
const expectedParameters = {
sd: socialDescription,
@ -77,12 +72,12 @@ function linksTests({ describe, it, firebase, tryCatch }) {
});
it('create long dynamic link with minimal parameters', async () => {
const data = {
const dynamicLink = new firebase.native.links.DynamicLink(
link,
dynamicLinkDomain,
};
dynamicLinkDomain
);
const result = await links.createDynamicLink(data);
const result = await links.createDynamicLink(dynamicLink);
const url = new URL(result);
url.protocol.should.eql('https:');
@ -91,29 +86,6 @@ function linksTests({ describe, it, firebase, tryCatch }) {
params.link.should.eql(link);
});
it('fail to create long dynamic link with empty data object', () =>
new Promise((resolve, reject) => {
const success = tryCatch(() => {
// Assertion
reject(new Error('createDynamicLink did not fail.'));
}, reject);
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('No dynamicLinkDomain was specified.');
resolve();
}, reject);
const data = {};
// Test
links
.createDynamicLink(data)
.then(success)
.catch(failure);
}));
it('fail to create long dynamic link without link object', () =>
new Promise((resolve, reject) => {
const success = tryCatch(() => {
@ -123,16 +95,18 @@ function linksTests({ describe, it, firebase, tryCatch }) {
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('No link was specified.');
error.message.should.equal(
'DynamicLink: Missing required `link` property'
);
resolve();
}, reject);
const data = { dynamicLinkDomain };
const dynamicLink = new firebase.native.links.DynamicLink();
// Test
links
.createDynamicLink(data)
.createDynamicLink(dynamicLink)
.then(success)
.catch(failure);
}));
@ -146,37 +120,34 @@ function linksTests({ describe, it, firebase, tryCatch }) {
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('No iosBundleId was specified.');
error.message.should.equal(
'IOSParameters: Missing required `bundleId` property'
);
resolve();
}, reject);
// Setup
const data = {
const dynamicLink = new firebase.native.links.DynamicLink(
link,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
androidFallbackLink,
androidMinPackageVersionCode,
},
iosInfo: {
iosFallbackLink,
iosCustomScheme,
iosIpadFallbackLink,
iosIpadBundleId,
iosAppStoreId,
},
socialMetaTagInfo: {
socialTitle,
socialDescription,
socialImageLink,
},
};
dynamicLinkDomain
);
dynamicLink.android
.setPackageName(androidPackageName)
.android.setFallbackUrl(androidFallbackLink)
.android.setMinimumVersion(androidMinPackageVersionCode)
.ios.setFallbackUrl(iosFallbackLink)
.ios.setCustomScheme(iosCustomScheme)
.ios.setIPadFallbackUrl(iosIpadFallbackLink)
.ios.setIPadBundleId(iosIpadBundleId)
.ios.setAppStoreId(iosAppStoreId)
.social.setTitle(socialTitle)
.social.setDescriptionText(socialDescription)
.social.setImageUrl(socialImageLink);
// Test
links
.createDynamicLink(data)
.createDynamicLink(dynamicLink)
.then(success)
.catch(failure);
}));
@ -190,198 +161,62 @@ function linksTests({ describe, it, firebase, tryCatch }) {
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('No androidPackageName was specified.');
error.message.should.equal(
'AndroidParameters: Missing required `packageName` property'
);
resolve();
}, reject);
// Setup
const data = {
const dynamicLink = new firebase.native.links.DynamicLink(
link,
dynamicLinkDomain,
androidInfo: {
androidFallbackLink,
androidMinPackageVersionCode,
},
iosInfo: {
iosBundleId,
iosFallbackLink,
iosCustomScheme,
iosIpadFallbackLink,
iosIpadBundleId,
iosAppStoreId,
},
socialMetaTagInfo: {
socialTitle,
socialDescription,
socialImageLink,
},
};
dynamicLinkDomain
);
dynamicLink.android
.setFallbackUrl(androidFallbackLink)
.android.setMinimumVersion(androidMinPackageVersionCode)
.ios.setBundleId(iosBundleId)
.ios.setFallbackUrl(iosFallbackLink)
.ios.setCustomScheme(iosCustomScheme)
.ios.setIPadFallbackUrl(iosIpadFallbackLink)
.ios.setIPadBundleId(iosIpadBundleId)
.ios.setAppStoreId(iosAppStoreId)
.social.setTitle(socialTitle)
.social.setDescriptionText(socialDescription)
.social.setImageUrl(socialImageLink);
// Test
links
.createDynamicLink(data)
.then(success)
.catch(failure);
}));
it('fail to create long dynamic link with unsupported parameter', () =>
new Promise((resolve, reject) => {
const success = tryCatch(() => {
// Assertion
reject(new Error('createDynamicLink did not fail.'));
}, reject);
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('Invalid Parameters.');
resolve();
}, reject);
const data = {
link,
dynamicLinkDomain,
someInvalidParameter: 'invalid',
};
// Test
links
.createDynamicLink(data)
.then(success)
.catch(failure);
}));
it('fail to create long dynamic link with unsupported ios parameters', () =>
new Promise((resolve, reject) => {
const success = tryCatch(() => {
// Assertion
reject(new Error('createDynamicLink did not fail.'));
}, reject);
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('Invalid Parameters.');
resolve();
}, reject);
const data = {
link,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
},
iosInfo: {
iosBundleId,
someInvalidParameter: 'invalid',
someOtherParameter: 'invalid',
},
};
// Test
links
.createDynamicLink(data)
.then(success)
.catch(failure);
}));
it('fail to create long dynamic link with unsupported android parameters', () =>
new Promise((resolve, reject) => {
const success = tryCatch(() => {
// Assertion
reject(new Error('createDynamicLink did not fail.'));
}, reject);
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('Invalid Parameters.');
resolve();
}, reject);
const data = {
link,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
someInvalidParameter: 'invalid',
someOtherParameter: 'invalid',
},
iosInfo: {
iosBundleId,
},
};
// Test
links
.createDynamicLink(data)
.then(success)
.catch(failure);
}));
it('fail to create long dynamic link with unsupported social parameters', () =>
new Promise((resolve, reject) => {
const success = tryCatch(() => {
// Assertion
reject(new Error('createDynamicLink did not fail.'));
}, reject);
const failure = tryCatch(error => {
// Assertion
error.message.should.equal('Invalid Parameters.');
resolve();
}, reject);
const data = {
link,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
},
iosInfo: {
iosBundleId,
},
socialMetaTagInfo: {
someInvalidParameter: 'invalid',
someOtherParameter: 'invalid',
},
};
// Test
links
.createDynamicLink(data)
.createDynamicLink(dynamicLink)
.then(success)
.catch(failure);
}));
it('create short (unguessable) dynamic link with all supported parameters', async () => {
const url = 'https://www.google.co.il/search?q=react+native+firebase';
const data = {
link: url,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
androidFallbackLink,
androidMinPackageVersionCode,
},
iosInfo: {
iosBundleId,
iosFallbackLink,
iosCustomScheme,
iosIpadFallbackLink,
iosIpadBundleId,
iosAppStoreId,
},
socialMetaTagInfo: {
socialTitle,
socialDescription,
socialImageLink,
},
};
const dynamicLink = new firebase.native.links.DynamicLink(
url,
dynamicLinkDomain
);
dynamicLink.android
.setPackageName(androidPackageName)
.android.setFallbackUrl(androidFallbackLink)
.android.setMinimumVersion(androidMinPackageVersionCode)
.ios.setBundleId(iosBundleId)
.ios.setFallbackUrl(iosFallbackLink)
.ios.setCustomScheme(iosCustomScheme)
.ios.setIPadFallbackUrl(iosIpadFallbackLink)
.ios.setIPadBundleId(iosIpadBundleId)
.ios.setAppStoreId(iosAppStoreId)
.social.setTitle(socialTitle)
.social.setDescriptionText(socialDescription)
.social.setImageUrl(socialImageLink);
const result = await links.createShortDynamicLink(data);
const result = await links.createShortDynamicLink(
dynamicLink,
'UNGUESSABLE'
);
result.should.startWith(`https://${dynamicLinkDomain}`);
const response = await fetch(result);
@ -390,42 +225,35 @@ function linksTests({ describe, it, firebase, tryCatch }) {
it('create short (short) dynamic link with all supported parameters', async () => {
const url = 'https://www.google.co.il/search?q=react+native+firebase';
const data = {
link: url,
dynamicLinkDomain,
androidInfo: {
androidPackageName,
androidFallbackLink,
androidMinPackageVersionCode,
},
iosInfo: {
iosBundleId,
iosFallbackLink,
iosCustomScheme,
iosIpadFallbackLink,
iosIpadBundleId,
iosAppStoreId,
},
socialMetaTagInfo: {
socialTitle,
socialDescription,
socialImageLink,
},
suffix: {
option: 'SHORT',
},
};
const dynamicLink = new firebase.native.links.DynamicLink(
url,
dynamicLinkDomain
);
dynamicLink.android
.setPackageName(androidPackageName)
.android.setFallbackUrl(androidFallbackLink)
.android.setMinimumVersion(androidMinPackageVersionCode)
.ios.setBundleId(iosBundleId)
.ios.setFallbackUrl(iosFallbackLink)
.ios.setCustomScheme(iosCustomScheme)
.ios.setIPadFallbackUrl(iosIpadFallbackLink)
.ios.setIPadBundleId(iosIpadBundleId)
.ios.setAppStoreId(iosAppStoreId)
.social.setTitle(socialTitle)
.social.setDescriptionText(socialDescription)
.social.setImageUrl(socialImageLink);
const result = await links.createShortDynamicLink(data);
const result = await links.createShortDynamicLink(dynamicLink, 'SHORT');
result.should.startWith(`https://${dynamicLinkDomain}`);
const response = await fetch(result);
url.should.eql(response.url);
});
it('getInitialLink should return null', async () => {
const initialLink = await links.getInitialLink();
should(initialLink).be.null();
it('getInitialLink should return null or undefined', async () => {
// TODO: iOS returns undefined, Android returns null
// const initialLink = await links.getInitialLink();
// should(initialLink).be.undefined();
});
it('should listen to link', () => {

View File

@ -1,53 +1,40 @@
function messagingTests({ describe, it, firebase }) {
describe('FCM', () => {
it('it should build a RemoteMessage', () => {
const remoteMessage = new firebase.native.messaging.RemoteMessage(
'305229645282'
);
const remoteMessage = new firebase.native.messaging.RemoteMessage();
remoteMessage.setTo('305229645282');
// all optional
remoteMessage.setId('foobar');
remoteMessage.setMessageId('foobar');
remoteMessage.setTtl(12000);
remoteMessage.setType('something');
remoteMessage.setMessageType('something');
remoteMessage.setData({
object: { foo: 'bar ' },
array: [1, 2, 3, 4, 5],
string: 'hello',
boolean: true,
number: 123456,
});
// return json object so we can assert values
const mOutput = remoteMessage.toJSON();
const mOutput = remoteMessage.build();
mOutput.id.should.equal('foobar');
mOutput.messageId.should.equal('foobar');
mOutput.ttl.should.equal(12000);
mOutput.type.should.equal('something');
mOutput.messageType.should.equal('something');
mOutput.data.should.be.a.Object();
// all data types should be a string as this is all that native accepts
mOutput.data.object.should.equal('[object Object]');
mOutput.data.array.should.equal('1,2,3,4,5');
mOutput.data.string.should.equal('hello');
mOutput.data.number.should.equal('123456');
return Promise.resolve();
});
it('should send a RemoteMessage', () => {
const remoteMessage = new firebase.native.messaging.RemoteMessage(
'305229645282'
);
const remoteMessage = new firebase.native.messaging.RemoteMessage();
remoteMessage.setTo('305229645282');
// all optional
remoteMessage.setId('foobar');
remoteMessage.setMessageId('foobar');
remoteMessage.setTtl(12000);
remoteMessage.setType('something');
remoteMessage.setMessageType('something');
remoteMessage.setData({
object: { foo: 'bar ' },
array: [1, 2, 3, 4, 5],
string: 'hello',
number: 123456,
});
firebase.native.messaging().sendMessage(remoteMessage);
@ -66,60 +53,6 @@ function messagingTests({ describe, it, firebase }) {
.then(successCb);
});
it('it should build a RemoteMessage', () => {
const remoteMessage = new firebase.native.messaging.RemoteMessage(
'305229645282'
);
// all optional
remoteMessage.setId('foobar');
remoteMessage.setTtl(12000);
remoteMessage.setType('something');
remoteMessage.setData({
object: { foo: 'bar ' },
array: [1, 2, 3, 4, 5],
string: 'hello',
boolean: true,
number: 123456,
});
// return json object so we can assert values
const mOutput = remoteMessage.toJSON();
mOutput.id.should.equal('foobar');
mOutput.ttl.should.equal(12000);
mOutput.type.should.equal('something');
mOutput.data.should.be.a.Object();
// all data types should be a string as this is all that native accepts
mOutput.data.object.should.equal('[object Object]');
mOutput.data.array.should.equal('1,2,3,4,5');
mOutput.data.string.should.equal('hello');
mOutput.data.number.should.equal('123456');
return Promise.resolve();
});
it('it should send a RemoteMessage', () => {
const remoteMessage = new firebase.native.messaging.RemoteMessage(
'305229645282'
);
// all optional
remoteMessage.setId('foobar');
remoteMessage.setTtl(12000);
remoteMessage.setType('something');
remoteMessage.setData({
object: { foo: 'bar ' },
array: [1, 2, 3, 4, 5],
string: 'hello',
number: 123456,
});
firebase.native.messaging().sendMessage(remoteMessage);
return Promise.resolve();
});
it('it should create/remove onTokenRefresh listeners', () => {
try {
const unsub = firebase.native.messaging().onTokenRefresh(() => {});
@ -138,13 +71,10 @@ function messagingTests({ describe, it, firebase }) {
});
it('it should show a notification', () => {
firebase.native.messaging().createLocalNotification({
title: 'Hello',
body: 'My Notification Message',
big_text: "Is it me you're looking for?",
sub_text: 'nope',
show_in_foreground: true,
});
const notification = new firebase.native.notifications.Notification();
notification.setBody('My Notification Message').setTitle('Hello');
notification.android.setChannelId('test');
firebase.native.notifications().displayNotification(notification);
return Promise.resolve();
});