2017-08-23 23:19:11 +01:00
|
|
|
import { Platform } from 'react-native';
|
|
|
|
|
2017-04-23 20:22:19 +01:00
|
|
|
import firebase from 'firebase';
|
2017-05-01 17:13:54 +01:00
|
|
|
import RNfirebase from './../firebase/firebase';
|
2017-04-23 20:22:19 +01:00
|
|
|
|
|
|
|
import DatabaseContents from './tests/support/DatabaseContents';
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E',
|
|
|
|
authDomain: 'rnfirebase-b9ad4.firebaseapp.com',
|
|
|
|
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
|
|
|
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
|
|
|
messagingSenderId: '305229645282',
|
|
|
|
};
|
|
|
|
|
2017-07-17 19:44:47 +01:00
|
|
|
const android = {
|
|
|
|
// firebase android sdk completely ignores client id
|
|
|
|
clientId: '305229645282-j8ij0jev9ut24odmlk9i215pas808ugn.apps.googleusercontent.com',
|
|
|
|
appId: '1:305229645282:android:efe37851d57e1d05',
|
|
|
|
apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E',
|
|
|
|
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
|
|
|
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
|
|
|
messagingSenderId: '305229645282',
|
|
|
|
projectId: 'rnfirebase-b9ad4',
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const ios = {
|
|
|
|
clientId: '305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib.apps.googleusercontent.com',
|
|
|
|
androidClientId: android.clientId,
|
|
|
|
appId: '1:305229645282:ios:7b45748cb1117d2d',
|
|
|
|
apiKey: 'AIzaSyDnVqNhxU0Biit9nCo4RorAh5ulQQwko3E',
|
|
|
|
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
|
|
|
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
|
|
|
messagingSenderId: '305229645282',
|
|
|
|
projectId: 'rnfirebase-b9ad4',
|
|
|
|
};
|
|
|
|
|
2017-04-23 20:22:19 +01:00
|
|
|
const instances = {
|
|
|
|
web: firebase.initializeApp(config),
|
2017-07-17 17:36:50 +01:00
|
|
|
native: RNfirebase.app(),
|
2017-07-17 19:44:47 +01:00
|
|
|
another: RNfirebase.initializeApp(Platform.OS === 'ios' ? ios : android, 'anotherApp'),
|
2017-04-23 20:22:19 +01:00
|
|
|
};
|
|
|
|
|
2017-07-17 17:36:50 +01:00
|
|
|
console.log('RNApps -->', RNfirebase.apps);
|
2017-07-12 15:49:33 +01:00
|
|
|
|
2017-07-17 20:56:08 +01:00
|
|
|
// natively initialized apps are already available at app run time,
|
|
|
|
// no need for ready checks
|
2017-07-17 19:44:47 +01:00
|
|
|
instances.native.auth().signInAnonymously().then((user) => {
|
|
|
|
console.log('defaultApp user ->', user.toJSON());
|
|
|
|
});
|
|
|
|
|
2017-07-17 20:56:08 +01:00
|
|
|
// dynamically initialized apps need a ready check
|
|
|
|
instances.another.onReady().then((app) => {
|
|
|
|
app.auth().signInAnonymously().then((user) => {
|
|
|
|
console.log('anotherApp user ->', user.toJSON());
|
|
|
|
});
|
2017-07-17 19:44:47 +01:00
|
|
|
});
|
|
|
|
|
2017-04-23 20:22:19 +01:00
|
|
|
instances.web.database().ref('tests/types').set(DatabaseContents.DEFAULT);
|
|
|
|
|
|
|
|
instances.web.database().ref('tests/priority').setWithPriority({
|
|
|
|
foo: 'bar',
|
|
|
|
}, 666);
|
|
|
|
|
2017-06-16 12:43:10 +01:00
|
|
|
instances.web.database().ref('tests/query').set(DatabaseContents.QUERY);
|
|
|
|
|
2017-04-23 20:22:19 +01:00
|
|
|
|
|
|
|
// instances.native.messaging().subscribeToTopic('fcm_test');
|
|
|
|
|
|
|
|
export default instances;
|