Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
🐛🐧📝 Issue #1433: Cordova Push V5 register () crashes App when initial…
Browse files Browse the repository at this point in the history
…ized with topicList
  • Loading branch information
macdonst committed Jan 6, 2017
1 parent fb4b533 commit 1d5723c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Attribute | Type | Default | Description
`android.clearBadge` | `boolean` | `false` | Optional. If `true` the icon badge will be cleared on init and before push messages are processed.
`android.clearNotifications` | `boolean` | `true` | Optional. If `true` the app clears all pending notifications when it is closed.
`android.forceShow` | `boolean` | `false` | Optional. Controls the behavior of the notification when app is in foreground. If `true` and app is in foreground, it will show a notification in the notification drawer, the same way as when the app is in background (and `on('notification')` callback will be called *only when the user clicks the notification*). When `false` and app is in foreground, the `on('notification')` callback will be called immediately.
`android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic.
`android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. Note: you should omit the `/topics/` prefix from each element of the array as the plugin will handle that for you.

#### Browser

Expand Down Expand Up @@ -75,7 +75,7 @@ Attribute | Type | Default | Description
--------- | ---- | ------- | -----------
`ios.senderID` | `string` | `undefined` (Native) | Maps to the project number in the Google Developer Console. Setting this uses GCM for notifications instead of native
`ios.gcmSandbox` | `boolean` | `false` | Whether to use prod or sandbox GCM setting. Defaults to false.
`ios.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. Note: only usable in conjunction with `senderID`.
`ios.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. Note: only usable in conjunction with `senderID`. Note: you should omit the `/topics/` prefix from each element of the array as the plugin will handle that for you.

##### How GCM on iOS works.

Expand Down
13 changes: 10 additions & 3 deletions src/android/com/adobe/phonegap/push/PushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,14 @@ private void clearAllNotifications() {
* @param String topic The topic name
* @return The topic path
*/
private String getTopicPath(String topic)
{
return "/topics/" + topic;
private String getTopicPath(String topic) {
if (topic.startsWith("/topics/")) {
return topic;
} else if (topic.startsWith("/topic/")) {
return topic.replace("/topic/", "/topics/");
} else {
return "/topics/" + topic;
}
}

private void subscribeToTopics(JSONArray topics, String registrationToken) throws IOException {
Expand All @@ -351,6 +356,8 @@ private void subscribeToTopic(String topic, String registrationToken) throws IOE
} catch (IOException e) {
Log.e(LOG_TAG, "Failed to subscribe to topic: " + topic, e);
throw e;
} catch (IllegalArgumentException argException) {
Log.e(LOG_TAG, "Cannot subscribe to topic [" + topic + "], illegal topic name");
}
}

Expand Down

0 comments on commit 1d5723c

Please sign in to comment.