Skip to content

Commit 5397a09

Browse files
committed
Allow override using the builder, so that small modifications can be made
1 parent 2b84d8d commit 5397a09

File tree

3 files changed

+6
-64
lines changed

3 files changed

+6
-64
lines changed

Parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
* {@link #onPushOpen(Context, Intent)}, or {@link #onPushDismiss(Context, Intent)}.
7171
* To make minor changes to the appearance of a notification, override
7272
* {@link #getSmallIconId(Context, Intent)} or {@link #getLargeIcon(Context, Intent)}. To completely
73-
* change the Notification generated, override {@link #getNotification(Context, Intent)}. To
73+
* change the Notification generated, override {@link #getNotificationBuilder(Context, Intent)}. To
7474
* change the NotificationChannel generated, override {@link #getNotificationChannel(Context, Intent)}. To
7575
* change how the NotificationChannel is created, override {@link #createNotificationChannel(Context, NotificationChannel)}.
7676
* To change the Activity launched when a user opens a Notification, override
@@ -212,7 +212,7 @@ protected void onPushReceive(Context context, Intent intent) {
212212
context.sendBroadcast(broadcastIntent);
213213
}
214214

215-
Notification notification = getNotification(context, intent);
215+
Notification notification = getNotificationBuilder(context, intent).build();
216216

217217
if (notification != null) {
218218
ParseNotificationManager.getInstance().showNotification(context, notification);
@@ -392,7 +392,7 @@ private JSONObject getPushData(Intent intent) {
392392
}
393393
}
394394
/**
395-
* Creates a {@link Notification} with reasonable defaults. If "alert" and "title" are
395+
* Creates a {@link NotificationCompat.Builder} with reasonable defaults. If "alert" and "title" are
396396
* both missing from data, then returns {@code null}. If the text in the notification is longer
397397
* than 38 characters long, the style of the notification will be set to
398398
* {@link android.app.Notification.BigTextStyle}.
@@ -409,7 +409,7 @@ private JSONObject getPushData(Intent intent) {
409409
*
410410
* @see ParsePushBroadcastReceiver#onPushReceive(Context, Intent)
411411
*/
412-
protected Notification getNotification(Context context, Intent intent) {
412+
protected NotificationCompat.Builder getNotificationBuilder(Context context, Intent intent) {
413413
JSONObject pushData = getPushData(intent);
414414
if (pushData == null || (!pushData.has("alert") && !pushData.has("title"))) {
415415
return null;
@@ -468,6 +468,6 @@ protected Notification getNotification(Context context, Intent intent) {
468468
&& alert.length() > ParsePushBroadcastReceiver.SMALL_NOTIFICATION_MAX_CHARACTER_LIMIT) {
469469
parseBuilder.setStyle(new NotificationCompat.Builder.BigTextStyle().bigText(alert));
470470
}
471-
return parseBuilder.build();
471+
return parseBuilder;
472472
}
473473
}

fcm/README.md

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,5 @@
11
# Parse SDK Android FCM
2-
FCM support for Parse Android apps
3-
4-
## Setup
5-
6-
### Installation
7-
8-
Add dependency to the application level `build.gradle` file.
9-
10-
```groovy
11-
dependencies {
12-
implementation 'com.parse:parse-android:latest.version.here'
13-
implementation 'com.parse:parse-android-fcm:latest.version.here'
14-
}
15-
```
16-
Then, follow Google's docs for [setting up an Firebase app](https://firebase.google.com/docs/android/setup). Although the steps are different for setting up FCM with Parse, it is also a good idea to read over the [Firebase FCM Setup](https://firebase.google.com/docs/cloud-messaging/android/client).
17-
18-
You will then need to register some things in your manifest, specifically:
19-
```xml
20-
<service
21-
android:name="com.parse.fcm.ParseFirebaseInstanceIdService"
22-
android:exported="true">
23-
<intent-filter>
24-
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
25-
</intent-filter>
26-
</service>
27-
```
28-
where `MyFirebaseInstanceIdService` is your own custom class which extends `ParseFirebaseInstanceIdService`.
29-
30-
Additional, you will register:
31-
32-
```xml
33-
<service
34-
android:name=".MyFirebaseMessagingService">
35-
<intent-filter>
36-
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
37-
</intent-filter>
38-
</service>
39-
```
40-
where `MyFirebaseMessagingService` extends `ParseFirebaseMessagingService`
41-
42-
After these services are registered in the Manifest, you then need to register your push broadcast receiver:
43-
```xml
44-
<receiver
45-
android:name="com.parse.ParsePushBroadcastReceiver"
46-
android:exported="false">
47-
<intent-filter>
48-
<action android:name="com.parse.push.intent.RECEIVE" />
49-
<action android:name="com.parse.push.intent.DELETE" />
50-
<action android:name="com.parse.push.intent.OPEN" />
51-
</intent-filter>
52-
</receiver>
53-
```
54-
55-
## Custom Notifications
56-
If you need to customize the notification that is sent out from a push, you can do so easily by extending `ParsePushBroadcastReceiver` with your own class and registering it instead in the Manifest.
57-
58-
## Instance ID Service
59-
If you need to store the FCM token elsewhere outside of Parse, you can create your own implementation of the `FirebaseInstanceIdService`, just make sure you are either extending `ParseFirebaseInstanceIdService` or are calling `ParseFCM.register(getApplicationContext());` in the `onTokenRefresh` method.
2+
FCM support for Parse Android apps. Follow the [guide](http://docs.parseplatform.org/tutorials/android-push-notifications/) for setup
603

614
## License
625
Copyright (c) 2015-present, Parse, LLC.

gcm/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Add dependency to the application level `build.gradle` file.
1212

1313
```groovy
1414
dependencies {
15-
implementation 'com.parse:parse-android:latest.version.here'
1615
implementation 'com.parse:parse-android-gcm:latest.version.here'
1716
}
1817
```

0 commit comments

Comments
 (0)