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 May 4, 2017
1 parent 006ca17 commit b5c0156
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
4 changes: 1 addition & 3 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ 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.
Expand Down Expand Up @@ -78,7 +77,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 @@ -102,7 +101,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 @@ -192,9 +192,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 @@ -217,11 +216,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 @@ -78,4 +78,5 @@ public interface PushConstants {
public static final String IMAGE_TYPE = "image-type";
public static final String IMAGE_TYPE_SQUARE = "square";
public static final String IMAGE_TYPE_CIRCLE = "circle";
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 @@ -437,6 +438,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 b5c0156

Please sign in to comment.