Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build google services #633

Draft
wants to merge 85 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
410095b
Versions defined
andrehtissot May 18, 2017
5774f8e
Removed info message, for a more silently build/install
andrehtissot May 19, 2017
ba1bf12
Fork is going to npm
andrehtissot May 28, 2017
4adead4
Fork is going to npm
andrehtissot May 28, 2017
5cb6622
Update README.md
andrehtissot May 28, 2017
b251d56
Update README.md
andrehtissot May 28, 2017
53d0788
Version changed to 2.1.2
andrehtissot May 28, 2017
fe97524
Update README.md
andrehtissot May 28, 2017
cdee90b
Version changed to 2.1.3 for npm update
andrehtissot May 28, 2017
0c564a9
Fixed base version
andrehtissot May 29, 2017
be2a96b
Version changed to 2.1.4 for npm update
andrehtissot May 29, 2017
90c94cc
Changed github link to reflect the npm name
andrehtissot Jun 1, 2017
6dd4846
changed version to 2.2.1
andrehtissot Jun 1, 2017
76d486b
Update README.md
andrehtissot Jun 6, 2017
ab6172d
version fixed
andrehtissot Aug 28, 2017
09b0713
Version changed to publish bug fix
andrehtissot Jan 5, 2018
81c1406
Changed version to publish fix
andrehtissot Jan 5, 2018
568a8ab
Fork updated with originals commits
andrehtissot Oct 6, 2018
a8c1979
fixed script error when platforms/android/res/values/strings.xml is n…
andrehtissot Oct 6, 2018
cb69e89
now the 'prepare' script looks into other dirs for the google-service…
andrehtissot Oct 6, 2018
6f39cbe
Badges added
andrehtissot Oct 6, 2018
a7274ea
Now the 'google-services.json' can be placed in the apps root directo…
andrehtissot Oct 28, 2018
163f3fb
Update README.md
andrehtissot Oct 28, 2018
9018f63
put title and body into data
anastasiaO Nov 24, 2018
69fa1a4
Merge pull request #1 from anastasiaO/master
andrehtissot Nov 27, 2018
db5299a
Replaced tabs for 4 spaces.
andrehtissot Nov 27, 2018
5480cce
Avoided remoteMessage.getNotification() null
andrehtissot Nov 27, 2018
da68aa1
Version upgraded to 2.3.0
andrehtissot Nov 27, 2018
67b4485
replaced jcenter repo with mavenCentral repo
Dec 10, 2018
0cdb146
Merge pull request #2 from razvanstanga/master
andrehtissot Dec 12, 2018
1ab580e
jcenter is still necessary on older installations
andrehtissot Dec 12, 2018
80a287d
Version upgraded to 2.4.0
andrehtissot Dec 12, 2018
f63e4a0
Update README.md
andrehtissot Dec 12, 2018
dd778da
added stars and forks badges
andrehtissot Jan 14, 2019
a5babb0
Update README.md
andrehtissot Jan 14, 2019
fbfec51
Update README.md
andretissot Jan 23, 2019
c38464d
Update README.md
andrehtissot Apr 15, 2019
62cb27a
[Android] Fix not execute FCMPluginActivity.OnCreate when pass click_…
mfdeveloper Jul 17, 2019
25db7ea
Merge pull request #4 from SerproLivre/fix-click-background
andrehtissot Aug 24, 2019
700a810
Create LICENSE
andrehtissot Aug 24, 2019
2edb674
[Android]: Added jitpack support with library Android Studio project
mfdeveloper Jun 7, 2019
4197f4c
[Android] Added env variables for FCM Android libs versions
mfdeveloper Jun 10, 2019
78f17d9
[WIP]: Added a example project with FCM show Token and get the messag…
mfdeveloper Jun 11, 2019
276fe11
[Android] Added data binding LiveData to show the token and FCM messa…
mfdeveloper Jun 12, 2019
a2c4810
[Android] Rename gradle variable to GRADLE_TOOLS_VERSION
mfdeveloper Jul 5, 2019
342e7c8
Small code tweaks
andrehtissot Aug 24, 2019
5c1f82f
updated version on podspec
andrehtissot Aug 24, 2019
cb91697
Merge pull request #6 from andrehtissot/3.0.0-beta
andrehtissot Aug 24, 2019
969334c
Fix mismatch of types on get token error callback
florian-diatelic Sep 9, 2019
70c69b6
Update google service and gradle tools
florian-diatelic Sep 13, 2019
6262796
Merge pull request #9 from florian-diatelic/fix-get-token-error
andrehtissot Sep 14, 2019
8401fb8
Set higher defaulf versions for GRADLE_TOOLS_VERSION and GOOGLE_SERVI…
andrehtissot Sep 14, 2019
ef36e47
Added method "hasPermission", useful on IOS.
andrehtissot Sep 16, 2019
68c3692
Added notes for Version 3.2.0
andrehtissot Sep 16, 2019
4812a56
Added downloaded per month badge
andrehtissot Sep 16, 2019
c413f8e
Experimenting with dependencies from cocoapods instead of embedding t…
andrehtissot Sep 30, 2019
947db88
Improved startup logic
andrehtissot Oct 1, 2019
776de6c
Avoids FIRApp.configure if it has already
andrehtissot Oct 1, 2019
dc1a69c
Added getAPNSToken method, as the plugin does get both.
andrehtissot Oct 2, 2019
d696fa0
Pre-4.0.0
andrehtissot Oct 8, 2019
155163b
Added publishing version date
andrehtissot Oct 12, 2019
20f4d7e
Update README.md
andrehtissot Oct 12, 2019
1b9e7cd
Update README.md
andrehtissot Oct 12, 2019
6bc34be
useful interfaces may to be exported
Oct 22, 2019
95e52ce
Merge pull request #11 from AlexisCaffa/patch-2
andrehtissot Oct 22, 2019
e213a63
onTokenRefresh should only to be used for FCM token
andrehtissot Oct 22, 2019
7046acd
Version upgraded to 4.0.1
andrehtissot Oct 24, 2019
9becf4e
Added a function to clear older notifications from notification center
YemYigit Oct 25, 2019
4cdc21d
Merge pull request #12 from YemYigit/master
andrehtissot Oct 26, 2019
4f9c6ac
adding log message for clearAllNotifications
andrehtissot Oct 26, 2019
8f9ea41
Slightly changed changelog
andrehtissot Oct 26, 2019
5bf415d
Version upgraded to 4.1.0
andrehtissot Oct 26, 2019
ec25017
Update README.md
andrehtissot Oct 26, 2019
381b526
Fixed breaking change with device token format in iOS 13
rich186 Nov 29, 2019
4cc3cc9
Merge pull request #14 from rich186/bugfix/ios13-device-token
andrehtissot Dec 3, 2019
3b778ae
Version upgraded to 4.1.1
andrehtissot Dec 3, 2019
0563a42
Update README.md
ketanyekale Dec 6, 2019
345cc78
Merge pull request #15 from ketanyekale/patch-1
andrehtissot Dec 10, 2019
54c322e
js script cleaned up a bit
andrehtissot Feb 24, 2020
09978bd
.prettier definitions added for js files
andrehtissot Feb 24, 2020
4e96fc1
Added ANDROID_DEFAULT_NOTIFICATION_ICON as a plugin variable
andrehtissot Feb 24, 2020
cdf884a
Version upgraded to 4.2.0
andrehtissot Feb 24, 2020
6598976
Added notes for version 4.2.0
andrehtissot Feb 24, 2020
c5bea74
FIX: build with microsoft cordova-plugin-code-push
aserranoo Mar 11, 2020
329c8b3
Merge pull request #1 from aserranoo/aserranoo-patch-1
aserranoo Mar 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"tabWidth": 4,
}
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
133 changes: 89 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,73 @@
# Google Firebase Cloud Messaging Cordova Push Plugin
> Extremely easy plug&play push notification plugin for Cordova applications with Google Firebase FCM.

>[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VF654BMGUPQTJ)
[![npm downloads](https://img.shields.io/npm/dt/cordova-plugin-fcm-with-dependecy-updated.svg)](https://www.npmjs.com/package/cordova-plugin-fcm-with-dependecy-updated)
[![npm per month](https://img.shields.io/npm/dm/cordova-plugin-fcm-with-dependecy-updated.svg)](https://www.npmjs.com/package/cordova-plugin-fcm-with-dependecy-updated)
[![npm version](https://img.shields.io/npm/v/cordova-plugin-fcm-with-dependecy-updated.svg)](https://www.npmjs.com/package/cordova-plugin-fcm-with-dependecy-updated)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![GitHub issues](https://img.shields.io/github/issues/andrehtissot/cordova-plugin-fcm-with-dependecy-updated.svg)](https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/issues)
[![GitHub forks](https://img.shields.io/github/forks/andrehtissot/cordova-plugin-fcm-with-dependecy-updated.svg)](https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/network)
[![GitHub stars](https://img.shields.io/github/stars/andrehtissot/cordova-plugin-fcm-with-dependecy-updated.svg)](https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/stargazers)
[![Known Vulnerabilities](https://snyk.io/test/github/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/badge.svg?targetFile=package.json)](https://snyk.io/test/github/andrehtissot/cordova-plugin-fcm-with-dependecy-updated?targetFile=package.json)
[![DeepScan grade](https://deepscan.io/api/teams/3417/projects/5068/branches/39495/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=3417&pid=5068&bid=39495)

### Version 4.2.0 (24/02/2020)

`ANDROID_DEFAULT_NOTIFICATION_ICON` included as a variable.

To define the default icon for notifications (`com.google.firebase.messaging.default_notification_icon`), install this plugin like:
```bash
cordova plugin add cordova-plugin-fcm-with-dependecy-updated --variable ANDROID_DEFAULT_NOTIFICATION_ICON="@mipmap/notification_icon"
```


### Version 4.1.0 (26/10/2019)

Older notifications can be cleared from notification center.
Works on both IOS and Android.

```javascript
//FCMPlugin.clearAllNotifications( successCallback(msg), errorCallback(err) );
FCMPlugin.clearAllNotifications();
```

### Version 4.0.0 (12/10/2019)
The old `FCMPlugin.getToken` is focused on retrieving the FCM Token.
For the IOS, APNS token can now be retrieved by the new method:

```javascript
FCMPlugin.getAPNSToken(
function(token) {
console.info("Retrieved token: "+token)
},
function(error) {
console.error(error);
}
);
```

On android, it will always return `null`.

The APNS token, once given, should not change for the same user (as commented on in https://stackoverflow.com/questions/6652242/does-the-apns-device-token-ever-change-once-created).

Although, contrary to APNS, the FCM tokens do expire, and for this reason, `FCMPlugin.onTokenRefresh` will be called with the new one FCM token.

#### Version 2.1.2 (03/06/2017)
### Version 3.2.0 (16/09/2019)
#### Checking for permissions
Useful for IOS. On android, it will always return `true`.

```javascript
FCMPlugin.hasPermission(function(doesIt){
// doesIt === true => yes, push was allowed
// doesIt === false => nope, push will not be available
// doesIt === null => still not answered, recommended checking again later
if(doesIt) {
haveFun();
}
});
```

### Version 2.1.2 (03/06/2017)
- Tested on Android and iOS using Cordova cli 6.4.0, Cordova android 6.0.0 and Cordova ios 4.3.1
- Available sdk functions: onTokenRefresh, getToken, subscribeToTopic, unsubscribeFromTopic and onNotification
- 'google-services.json' and 'GoogleService-Info.plist' are added automatically from Cordova project root to platform folders
Expand All @@ -13,31 +77,29 @@
## Installation
Make sure you have ‘google-services.json’ for Android or ‘GoogleService-Info.plist’ for iOS in your Cordova project root folder. You don´t need to configure anything else in order to have push notification working for both platforms, everything is magic.
```Bash
cordova plugin add cordova-plugin-fcm

cordova plugin add cordova-plugin-fcm-with-dependecy-updated
```

#### Firebase configuration files
### Firebase configuration files
Get the needed configuration files for Android or iOS from the Firebase Console (see docs: https://firebase.google.com/docs/).

#### Android compilation details
### Android compilation details
Put the downloaded file 'google-services.json' in the Cordova project root folder.

You will need to ensure that you have installed the appropiate Android SDK libraries.


:warning: For Android >5.0 status bar icon, you must include transparent solid color icon with name 'fcm_push_icon.png' in the 'res' folder in the same way you add the other application icons.
If you do not set this resource, then the SDK will use the default icon for your app which may not meet the standards for Android >5.0.

#### iOS compilation details
### iOS compilation details
Put the downloaded file 'GoogleService-Info.plist' in the Cordova project root folder.

## Usage

:warning: It's highly recommended to use REST API to send push notifications because Firebase console does not have all the functionalities. **Pay attention to the payload example in order to use the plugin properly**.
You can also test your notifications with the free testing server: https://cordova-plugin-fcm.appspot.com

#### Receiving Token Refresh
### Receiving Token Refresh

```javascript
//FCMPlugin.onTokenRefresh( onTokenRefreshCallback(token) );
Expand All @@ -47,7 +109,7 @@ FCMPlugin.onTokenRefresh(function(token){
});
```

#### Get token
### Get token

```javascript
//FCMPlugin.getToken( successCallback(token), errorCallback(err) );
Expand All @@ -57,7 +119,7 @@ FCMPlugin.getToken(function(token){
});
```

#### Subscribe to topic
### Subscribe to topic

```javascript
//FCMPlugin.subscribeToTopic( topic, successCallback(msg), errorCallback(err) );
Expand All @@ -66,14 +128,14 @@ FCMPlugin.getToken(function(token){
FCMPlugin.subscribeToTopic('topicExample');
```

#### Unsubscribe from topic
### Unsubscribe from topic

```javascript
//FCMPlugin.unsubscribeFromTopic( topic, successCallback(msg), errorCallback(err) );
FCMPlugin.unsubscribeFromTopic('topicExample');
```

#### Receiving push notification data
### Receiving push notification data

```javascript
//FCMPlugin.onNotification( onNotificationCallback(data), successCallback(msg), errorCallback(err) )
Expand All @@ -89,7 +151,7 @@ FCMPlugin.onNotification(function(data){
});
```

#### Send notification. Payload example (REST API)
### Send notification. Payload example (REST API)
Full documentation: https://firebase.google.com/docs/cloud-messaging/http-server-ref
Free testing server: https://cordova-plugin-fcm.appspot.com
```javascript
Expand Down Expand Up @@ -120,37 +182,20 @@ Free testing server: https://cordova-plugin-fcm.appspot.com
//priority: must be set to "high" for delivering notifications on closed iOS apps
//restricted_package_name: optional field if you want to send only to a restricted app package (i.e: com.myapp.test)
```

## How it works
Send a push notification to a single device or topic.
- 1.a Application is in foreground:
- The notification data is received in the JavaScript callback without notification bar message (this is the normal behaviour of mobile push notifications).
- 1.b Application is in background or closed:
- The device displays the notification message in the device notification bar.
- If the user taps the notification, the application comes to foreground and the notification data is received in the JavaScript callback.
- If the user does not tap the notification but opens the applicacion, nothing happens until the notification is tapped.

+ Application is in foreground:

## License
```
The MIT License

Copyright (c) 2017 Felipe Echanique Torres (felipe.echanique in the gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
The notification data is received in the JavaScript callback without notification bar message (this is the normal behaviour of mobile push notifications).

+ Application is in background or closed:

1. The device displays the notification message in the device notification bar.
2. If the user taps the notification, the application comes to foreground and the notification data is received in the JavaScript callback.
3. If the user does not tap the notification but opens the applicacion, nothing happens until the notification is tapped.


## Authorship
This is a fork from https://github.com/fechanique/cordova-plugin-fcm, which has dependencies versions upgraded, jitpack and cocoapods support, and newer features.
13 changes: 13 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
4 changes: 4 additions & 0 deletions android/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions android/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions android/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
46 changes: 46 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.gae.scaffolder.plugin"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

testOptions {
unitTests {
includeAndroidResources = true
}
}

dataBinding {
enabled = true
}
}

dependencies {
implementation project(path: ':lib')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation "com.google.firebase:firebase-core:${rootProject.ext.FCM_CORE_VERSION}"
implementation "com.google.firebase:firebase-messaging:${rootProject.ext.FCM_VERSION}"
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibraryVersion}"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.7.22'
testImplementation 'org.robolectric:robolectric:4.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'
21 changes: 21 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading