-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample.js
98 lines (72 loc) · 1.95 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var FirebaseCore = require('firebase.core');
var FirebaseAnalytics = require('firebase.analytics');
var FirebasePerformance = require('firebase.performance');
var FirebaseAuth = require('firebase.auth');
var FirebaseCloudMessaging = require('firebase.cloudmessaging');
// Configure Firebase. Required for all (!) services
FirebaseCore.configure();
//
// ---- Analytics ----
//
// Get the App Instance ID
Ti.API.info('App Instance ID: ' + FirebaseAnalytics.appInstanceID);
// Log to the Firebase console
FirebaseAnalytics.log('My Event', { /* Optional arguments */ });
// Set user-property string
FirebaseAnalytics.setUserPropertyString({
name: 'My Name',
value: 'My Value'
});
// Set User-ID
FirebaseAnalytics.setUserID('MyUserID');
//
// ---- Performance ----
//
// Start the named trace
FirebasePerformance.startTrace('trace_name');
// Increment the counter value
FirebasePerformance.incrementCounter('trace_name', 'counter_name', 1); // Trace name, counter name, increment (optional)
// Stop the named trace
FirebasePerformance.stopTrace('trace_name');
// Manually disable data collection (enabled by default)
FirebasePerformance.dataCollectionEnabled = false;
// Returns all trace-names
Ti.API.log(FirebasePerformance.allTraces);
//
// ---- Authentication ----
//
FirebaseAuth.signInWithEmail({
email: '[email protected]',
password: 'T1t4n1umR0ck$***',
success: function(e) {
alert('Logged in!');
},
error: function(e) {
Ti.API.error('Error logging in: ' + e.error);
}
});
//
// ---- Cloud Messaging ---
//
// Register for push notifications
FirebaseCloudMessaging.registerForPushNotifications();
// Subscribe to topic
FirebaseCloudMessaging.subcribeToTopic('titanium');
// Unsubscribe from topic
FirebaseCloudMessaging.unsubcribeFromTopic('titanium');
//
// ---- Storage ---
//
// TODO: Write example
//
// ---- Crash Reporting ---
//
// TODO: Write example
//
// ---- Remote Config ---
//
// TODO: Write example
//
// ---- Database ---
//
// TODO: Write example