Skip to content

Commit 094d097

Browse files
authored
fix(pinpoint): Remove GCM service as target class usage as it is no longer allowed in Android 12. (#3110)
* Remove GCM service class usage as it is no longer allowed in Android 12.
1 parent da2b058 commit 094d097

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ public CampaignPushResult handleFCMCampaignPush(final String from,
183183
*
184184
* @param from the from string received by the GCM service
185185
* @param data the bundle received from the GCM service
186-
* @param serviceClass the class extending GCMListenerService that handles
187-
* receiving GCM messages.
186+
* @param serviceClass No longer used due to Android 12 restrictions
188187
* @return {@link PushResult}.
189188
*
190189
* @deprecated Use {@link #handleCampaignPush(NotificationDetails)} instead.
@@ -195,7 +194,6 @@ public CampaignPushResult handleGCMCampaignPush(final String from, final Bundle
195194
NotificationDetails.builder()
196195
.from(from)
197196
.bundle(data)
198-
.serviceClass(serviceClass)
199197
.intentAction(GCM_INTENT_ACTION);
200198
return handleCampaignPush(notificationDetailsBuilder.build());
201199
}

aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationDetails.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public static NotificationDetailsBuilder builder() {
9797
* new NotificationDetails.builder()
9898
* .from(from)
9999
* .bundle(bundle)
100-
* .serviceClass(serviceClass)
101100
* .intentAction(NotificationClient.GCM_INTENT_ACTION)
102101
* .build();
103102
*
@@ -111,7 +110,6 @@ public static NotificationDetailsBuilder builder() {
111110
* ADM example:
112111
* new NotificationDetails.builder()
113112
* .intent(intent)
114-
* .serviceClass(serviceClass)
115113
* .intentAction(NotificationClient.ADM_INTENT_ACTION)
116114
* .build();
117115
*
@@ -123,7 +121,6 @@ public static NotificationDetailsBuilder builder() {
123121
public static class NotificationDetailsBuilder {
124122
private String from;
125123
private Bundle bundle;
126-
private Class<? extends Service> serviceClass;
127124
private String intentAction;
128125
private Map<String, String> mapData;
129126
private Intent intent;
@@ -156,11 +153,12 @@ public NotificationDetailsBuilder bundle(Bundle bundle) {
156153
/**
157154
* The Android Service class that received the push notification.
158155
* @param serviceClass Android service class that received the push notification
156+
* @deprecated The set value is no longer used due to Android 12 restrictions
159157
* @return {@link NotificationDetailsBuilder}
160158
*/
161159
@SuppressWarnings("checkstyle:hiddenfield")
160+
@Deprecated
162161
public NotificationDetailsBuilder serviceClass(Class<? extends Service> serviceClass) {
163-
this.serviceClass = serviceClass;
164162
return this;
165163
}
166164

@@ -229,7 +227,7 @@ public NotificationDetails build() {
229227
if (NotificationClient.GCM_INTENT_ACTION.equals(intentAction)) {
230228
notificationDetails.setFrom(from);
231229
notificationDetails.setBundle(bundle);
232-
notificationDetails.setTargetClass(serviceClass);
230+
notificationDetails.setTargetClass(PinpointNotificationActivity.class);
233231
notificationDetails.setIntentAction(intentAction);
234232
notificationDetails.setNotificationChannelId(notificationChannelId);
235233
}

0 commit comments

Comments
 (0)