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

Commit

Permalink
Issue #689: Remove sender id from PushNotification init Android options
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Jan 12, 2017
1 parent aa6e3ce commit 10c5153
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
6 changes: 2 additions & 4 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ All available option attributes are described bellow. Currently, there are no Wi

Attribute | Type | Default | Description
--------- | ---- | ------- | -----------
`android.senderID` | `string` | | Maps to the project number in the Google Developer Console.
`android.icon` | `string` | | Optional. The name of a drawable resource to use as the small-icon. The name should not include the extension.
`android.iconColor` | `string` | | Optional. Sets the background color of the small icon on Android 5.0 and greater. [Supported Formats](http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String))
`android.sound` | `boolean` | `true` | Optional. If `true` it plays the sound specified in the push data or the default system sound.
`android.vibrate` | `boolean` | `true` | Optional. If `true` the device vibrates on receipt of notification.
`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. Note: you should omit the `/topics/` prefix from each element of the array as the plugin will handle that for you.
`android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic.

#### Browser

Expand Down Expand Up @@ -75,7 +74,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`. Note: you should omit the `/topics/` prefix from each element of the array as the plugin will handle that for you.
`ios.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic.

##### How GCM on iOS works.

Expand All @@ -99,7 +98,6 @@ Make sure that the certificate you build with matches your `gcmSandbox` value.
```javascript
var push = PushNotification.init({
android: {
senderID: "12345679"
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
Expand Down
1 change: 0 additions & 1 deletion docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ phonegap create my-app --template phonegap-template-push
```javascript
var push = PushNotification.init({
android: {
senderID: "12345679"
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
Expand Down
6 changes: 2 additions & 4 deletions docs/PAYLOAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ By default the icon displayed in your push notification will be your apps icon.
```javascript
var push = PushNotification.init({
"android": {
"senderID": "12345679"
},
browser: {
"browser": {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
"ios": {
Expand All @@ -154,11 +153,10 @@ In order to get a better user experience you can specify an alternate icon and b
```javascript
var push = PushNotification.init({
"android": {
"senderID": "123456789",
"icon": "phonegap",
"iconColor": "blue"
},
browser: {
"browser": {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
"ios": {
Expand Down
3 changes: 1 addition & 2 deletions docs/TYPESCRIPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ All available attributes and properties will have autocomplete support and type
```typescript
let push = PushNotification.init({
android: {
senderID: "12345679"
},
ios: {
alert: "true",
Expand Down Expand Up @@ -69,4 +68,4 @@ push.on('notification', (data: my.custom.NotificationEventResponse) => {
## Outdated definitions

Is our definition file at DefinitelyTyped outdated? Is there any improvements that could be done?
We welcome any contribution, and they should be done through issues created [there](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/new).
We welcome any contribution, and they should be done through issues created [there](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/new).
1 change: 1 addition & 0 deletions src/android/com/adobe/phonegap/push/PushConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ public interface PushConstants {
public static final String MP_MESSAGE = "mp_message";
public static final String START_IN_BACKGROUND = "cdvStartInBackground";
public static final String FORCE_START = "force-start";
public static final String GOOGLE_APP_ID = "google_app_id";
}
10 changes: 9 additions & 1 deletion src/android/com/adobe/phonegap/push/PushPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.adobe.phonegap.push;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void run() {

Log.v(LOG_TAG, "execute: jo=" + jo.toString());

senderID = jo.getString(SENDER_ID);
senderID = getStringResourceByName(GOOGLE_APP_ID);

Log.v(LOG_TAG, "execute: senderID=" + senderID);

Expand Down Expand Up @@ -409,6 +410,13 @@ else if (strValue.startsWith("[")) {
return null;
}

private String getStringResourceByName(String aString) {
Activity activity = cordova.getActivity();
String packageName = activity.getPackageName();
int resId = activity.getResources().getIdentifier(aString, "string", packageName);
return activity.getString(resId);
}

public static boolean isInForeground() {
return gForeground;
}
Expand Down

0 comments on commit 10c5153

Please sign in to comment.