Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit f4b10a8

Browse files
committed
Remove GCM and C2DM references from README.md (Deprecated)
1 parent cc66810 commit f4b10a8

File tree

5 files changed

+96
-78
lines changed

5 files changed

+96
-78
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2323
- Upgrade ShortCutBadger to 1.1.22 [#646](https://github.com/zo0r/react-native-push-notification/pull/646)
2424
- Upgrade exemple to React-Native 0.62.2
2525
- Remove Types from the code use [@types/react-native-push-notification](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-native-push-notification) instead.
26+
- Remove GCM and C2DM references in README.md
2627

2728
### Possible Breaking change
2829

README.md

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The component uses PushNotificationIOS for the iOS part.
4747

4848
## Android manual Installation
4949

50-
**NOTE: `play-service-gcm` and `firebase-messaging`, prior to version 15 requires to have the same version number in order to work correctly at build time and at run time. To use a specific version:**
50+
**NOTE: `firebase-messaging`, prior to version 15 requires to have the same version number in order to work correctly at build time and at run time. To use a specific version:**
5151

5252
In your `android/build.gradle`
5353

@@ -80,13 +80,7 @@ In your `android/app/src/main/AndroidManifest.xml`
8080

8181
```xml
8282
.....
83-
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
8483
<uses-permission android:name="android.permission.WAKE_LOCK" />
85-
<permission
86-
android:name="${applicationId}.permission.C2D_MESSAGE"
87-
android:protectionLevel="signature" />
88-
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
89-
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
9084

9185
<uses-permission android:name="android.permission.VIBRATE" />
9286
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
@@ -100,18 +94,6 @@ In your `android/app/src/main/AndroidManifest.xml`
10094
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
10195
android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->
10296

103-
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
104-
<receiver
105-
android:name="com.google.android.gms.gcm.GcmReceiver"
106-
android:exported="true"
107-
android:permission="com.google.android.c2dm.permission.SEND" >
108-
<intent-filter>
109-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
110-
<category android:name="${applicationId}" />
111-
</intent-filter>
112-
</receiver>
113-
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
114-
11597
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
11698
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
11799
<intent-filter>
@@ -120,25 +102,13 @@ In your `android/app/src/main/AndroidManifest.xml`
120102
</receiver>
121103
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
122104

123-
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
124-
<service
125-
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm"
126-
android:exported="false" >
127-
<intent-filter>
128-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
129-
</intent-filter>
130-
</service>
131-
<!-- </ Only if you're using GCM or localNotificationSchedule() > -->
132-
133-
<!-- < Else > -->
134105
<service
135106
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
136107
android:exported="false" >
137108
<intent-filter>
138109
<action android:name="com.google.firebase.MESSAGING_EVENT" />
139110
</intent-filter>
140111
</service>
141-
<!-- </Else> -->
142112
.....
143113
```
144114

@@ -207,8 +177,8 @@ PushNotification.configure({
207177
notification.finish(PushNotificationIOS.FetchResult.NoData);
208178
},
209179

210-
// ANDROID ONLY: GCM or FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
211-
senderID: "YOUR GCM (OR FCM) SENDER ID",
180+
// ANDROID ONLY: FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
181+
senderID: "YOUR FCM SENDER ID",
212182

213183
// IOS ONLY (optional): default: all - Permissions to register.
214184
permissions: {
@@ -233,7 +203,6 @@ PushNotification.configure({
233203
## Example app
234204

235205
Example folder contains an example app to demonstrate how to use this package. The notification Handling is done in `NotifService.js`. For Remote notifications, configure your SenderId in `app.json`. You can also edit it directly in the app.
236-
To send Push notifications, you can use the online tool [PushWatch](https://www.pushwatch.com/gcm/).
237206

238207
Please test your PRs with this example app before submitting them. It'll help maintaining this repo.
239208

example/App.js

Lines changed: 87 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,101 @@
66
* @flow
77
*/
88

9-
import React, { Component } from 'react';
10-
import { TextInput, StyleSheet, Text, View, TouchableOpacity, Alert } from 'react-native';
9+
import React, {Component} from 'react';
10+
import {
11+
TextInput,
12+
StyleSheet,
13+
Text,
14+
View,
15+
TouchableOpacity,
16+
Alert,
17+
} from 'react-native';
1118
import NotifService from './NotifService';
1219
import appConfig from './app.json';
1320

1421
export default class App extends Component {
1522
constructor(props) {
1623
super(props);
1724
this.state = {
18-
senderId: appConfig.senderID
25+
senderId: appConfig.senderID,
1926
};
2027

21-
this.notif = new NotifService(this.onRegister.bind(this), this.onNotif.bind(this));
28+
this.notif = new NotifService(
29+
this.onRegister.bind(this),
30+
this.onNotif.bind(this),
31+
);
2232
}
2333

2434
render() {
2535
return (
2636
<View style={styles.container}>
27-
<Text style={styles.title}>Example app react-native-push-notification</Text>
37+
<Text style={styles.title}>
38+
Example app react-native-push-notification
39+
</Text>
2840
<View style={styles.spacer}></View>
29-
<TextInput style={styles.textField} value={this.state.registerToken} placeholder="Register token" />
41+
<TextInput
42+
style={styles.textField}
43+
value={this.state.registerToken}
44+
placeholder="Register token"
45+
/>
3046
<View style={styles.spacer}></View>
3147

32-
<TouchableOpacity style={styles.button} onPress={() => { this.notif.localNotif() }}><Text>Local Notification (now)</Text></TouchableOpacity>
33-
<TouchableOpacity style={styles.button} onPress={() => { this.notif.scheduleNotif() }}><Text>Schedule Notification in 30s</Text></TouchableOpacity>
34-
<TouchableOpacity style={styles.button} onPress={() => { this.notif.cancelNotif() }}><Text>Cancel last notification (if any)</Text></TouchableOpacity>
35-
<TouchableOpacity style={styles.button} onPress={() => { this.notif.cancelAll() }}><Text>Cancel all notifications</Text></TouchableOpacity>
36-
<TouchableOpacity style={styles.button} onPress={() => { this.notif.checkPermission(this.handlePerm.bind(this)) }}><Text>Check Permission</Text></TouchableOpacity>
48+
<TouchableOpacity
49+
style={styles.button}
50+
onPress={() => {
51+
this.notif.localNotif();
52+
}}>
53+
<Text>Local Notification (now)</Text>
54+
</TouchableOpacity>
55+
<TouchableOpacity
56+
style={styles.button}
57+
onPress={() => {
58+
this.notif.scheduleNotif();
59+
}}>
60+
<Text>Schedule Notification in 30s</Text>
61+
</TouchableOpacity>
62+
<TouchableOpacity
63+
style={styles.button}
64+
onPress={() => {
65+
this.notif.cancelNotif();
66+
}}>
67+
<Text>Cancel last notification (if any)</Text>
68+
</TouchableOpacity>
69+
<TouchableOpacity
70+
style={styles.button}
71+
onPress={() => {
72+
this.notif.cancelAll();
73+
}}>
74+
<Text>Cancel all notifications</Text>
75+
</TouchableOpacity>
76+
<TouchableOpacity
77+
style={styles.button}
78+
onPress={() => {
79+
this.notif.checkPermission(this.handlePerm.bind(this));
80+
}}>
81+
<Text>Check Permission</Text>
82+
</TouchableOpacity>
3783

3884
<View style={styles.spacer}></View>
39-
<TextInput style={styles.textField} value={this.state.senderId} onChangeText={(e) => {this.setState({ senderId: e })}} placeholder="GCM ID" />
40-
<TouchableOpacity style={styles.button} onPress={() => { this.notif.configure(this.onRegister.bind(this), this.onNotif.bind(this), this.state.senderId) }}><Text>Configure Sender ID</Text></TouchableOpacity>
85+
<TextInput
86+
style={styles.textField}
87+
value={this.state.senderId}
88+
onChangeText={(e) => {
89+
this.setState({senderId: e});
90+
}}
91+
placeholder="FCM ID"
92+
/>
93+
<TouchableOpacity
94+
style={styles.button}
95+
onPress={() => {
96+
this.notif.configure(
97+
this.onRegister.bind(this),
98+
this.onNotif.bind(this),
99+
this.state.senderId,
100+
);
101+
}}>
102+
<Text>Configure Sender ID</Text>
103+
</TouchableOpacity>
41104
{this.state.gcmRegistered && <Text>GCM Configured !</Text>}
42105

43106
<View style={styles.spacer}></View>
@@ -46,9 +109,9 @@ export default class App extends Component {
46109
}
47110

48111
onRegister(token) {
49-
Alert.alert("Registered !", JSON.stringify(token));
112+
Alert.alert('Registered !', JSON.stringify(token));
50113
console.log(token);
51-
this.setState({ registerToken: token.token, gcmRegistered: true });
114+
this.setState({registerToken: token.token, gcmRegistered: true});
52115
}
53116

54117
onNotif(notif) {
@@ -57,11 +120,10 @@ export default class App extends Component {
57120
}
58121

59122
handlePerm(perms) {
60-
Alert.alert("Permissions", JSON.stringify(perms));
123+
Alert.alert('Permissions', JSON.stringify(perms));
61124
}
62125
}
63126

64-
65127
const styles = StyleSheet.create({
66128
container: {
67129
flex: 1,
@@ -76,26 +138,26 @@ const styles = StyleSheet.create({
76138
},
77139
button: {
78140
borderWidth: 1,
79-
borderColor: "#000000",
141+
borderColor: '#000000',
80142
margin: 5,
81143
padding: 5,
82-
width: "70%",
83-
backgroundColor: "#DDDDDD",
144+
width: '70%',
145+
backgroundColor: '#DDDDDD',
84146
borderRadius: 5,
85147
},
86148
textField: {
87149
borderWidth: 1,
88-
borderColor: "#AAAAAA",
150+
borderColor: '#AAAAAA',
89151
margin: 5,
90152
padding: 5,
91-
width: "70%"
153+
width: '70%',
92154
},
93155
spacer: {
94156
height: 10,
95157
},
96158
title: {
97-
fontWeight: "bold",
159+
fontWeight: 'bold',
98160
fontSize: 20,
99-
textAlign: "center",
100-
}
161+
textAlign: 'center',
162+
},
101163
});

example/NotifService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ export default class NotifService {
77
this.lastId = 0;
88
}
99

10-
configure(onRegister, onNotification, gcm = '') {
10+
configure(onRegister, onNotification, fcm = '') {
1111
PushNotification.configure({
1212
// (optional) Called when Token is generated (iOS and Android)
1313
onRegister: onRegister, //this._onRegister.bind(this),
1414

1515
// (required) Called when a remote or local notification is opened or received
1616
onNotification: onNotification, //this._onNotification,
1717

18-
// ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
19-
senderID: gcm,
18+
// ANDROID ONLY: FCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
19+
senderID: fcm,
2020

2121
// IOS ONLY (optional): default: all - Permissions to register.
2222
permissions: {

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
99

1010
<uses-permission android:name="android.permission.WAKE_LOCK" />
11-
<permission
12-
android:name="${applicationId}.permission.C2D_MESSAGE"
13-
android:protectionLevel="signature" />
14-
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
1511

1612
<application
1713
android:name=".MainApplication"
@@ -33,32 +29,22 @@
3329
</activity>
3430
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
3531

36-
<receiver
37-
android:name="com.google.android.gms.gcm.GcmReceiver"
38-
android:exported="true"
39-
android:permission="com.google.android.c2dm.permission.SEND" >
40-
<intent-filter>
41-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
42-
<category android:name="${applicationId}" />
43-
</intent-filter>
44-
</receiver>
45-
4632
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
4733
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
4834
<intent-filter>
4935
<action android:name="android.intent.action.BOOT_COMPLETED" />
5036
</intent-filter>
5137
</receiver>
5238
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
39+
5340
<service
5441
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
5542
android:exported="false" >
5643
<intent-filter>
57-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
44+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
5845
</intent-filter>
5946
</service>
6047

61-
6248
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
6349
android:value="Example-Channel"/>
6450
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"

0 commit comments

Comments
 (0)