Commit 90d0265c authored by Libin Lu's avatar Libin Lu

fix example

parent 98939636
...@@ -10,7 +10,8 @@ import { ...@@ -10,7 +10,8 @@ import {
Text, Text,
TouchableOpacity, TouchableOpacity,
View, View,
Clipboard Clipboard,
Platform
} from 'react-native'; } from 'react-native';
import FCM from "react-native-fcm"; import FCM from "react-native-fcm";
...@@ -157,15 +158,15 @@ export default class App extends Component { ...@@ -157,15 +158,15 @@ export default class App extends Component {
Remote notif won't be available to iOS emulators Remote notif won't be available to iOS emulators
</Text> </Text>
<TouchableOpacity onPress={() => firebaseClient.sendRemoteNotification(token)} style={styles.button}> <TouchableOpacity onPress={() => this.sendRemoteNotification(token)} style={styles.button}>
<Text style={styles.buttonText}>Send Remote Notification</Text> <Text style={styles.buttonText}>Send Remote Notification</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity onPress={() => firebaseClient.sendRemoteData(token)} style={styles.button}> <TouchableOpacity onPress={() => this.sendRemoteData(token)} style={styles.button}>
<Text style={styles.buttonText}>Send Remote Data</Text> <Text style={styles.buttonText}>Send Remote Data</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity onPress={() => firebaseClient.sendRemoteNotificationWithData(token)} style={styles.button}> <TouchableOpacity onPress={() => this.sendRemoteNotificationWithData(token)} style={styles.button}>
<Text style={styles.buttonText}>Send Remote Notification With Data</Text> <Text style={styles.buttonText}>Send Remote Notification With Data</Text>
</TouchableOpacity> </TouchableOpacity>
......
import FirebaseConstants from "./FirebaseConstants"; import FirebaseConstants from "./FirebaseConstants";
import { Platform, Alert } from "react-native"; import { Alert } from "react-native";
const API_URL = "https://fcm.googleapis.com/fcm/send"; const API_URL = "https://fcm.googleapis.com/fcm/send";
class FirebaseClient { class FirebaseClient {
constructor() {
this.sendData = this.sendData.bind(this);
this.sendNotification = this.sendNotification.bind(this);
this.sendNotificationWithData = this.sendNotificationWithData.bind(this);
}
async send(body, type) { async send(body, type) {
if(FirebaseClient.KEY === 'YOUR_API_KEY'){ if(FirebaseClient.KEY === 'YOUR_API_KEY'){
Alert.alert('Set your API_KEY in app/FirebaseConstants.js') Alert.alert('Set your API_KEY in app/FirebaseConstants.js')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment