├── .prettierignore ├── android ├── .npmignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── getcapacitor │ │ │ └── community │ │ │ └── fcm │ │ │ └── FCMPlugin.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── getcapacitor │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── getcapacitor │ │ └── android │ │ └── ExampleInstrumentedTest.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── settings.gradle ├── proguard-rules.pro ├── gradle.properties ├── build.gradle ├── gradlew.bat └── gradlew ├── example ├── .gradle │ ├── 4.10.1 │ │ ├── gc.properties │ │ ├── fileChanges │ │ │ └── last-build.bin │ │ ├── fileHashes │ │ │ └── fileHashes.lock │ │ └── taskHistory │ │ │ └── taskHistory.lock │ └── buildOutputCleanup │ │ ├── cache.properties │ │ └── buildOutputCleanup.lock ├── src │ ├── app │ │ ├── home │ │ │ ├── home.page.scss │ │ │ ├── home.page.html │ │ │ ├── home.module.ts │ │ │ ├── home.page.spec.ts │ │ │ └── home.page.ts │ │ ├── app.component.html │ │ ├── app.component.ts │ │ ├── app.scss │ │ ├── app-routing.module.ts │ │ ├── app.module.ts │ │ └── app.component.spec.ts │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── assets │ │ ├── icon │ │ │ └── favicon.png │ │ └── shapes.svg │ ├── zone-flags.ts │ ├── tsconfig.app.json │ ├── tslint.json │ ├── tsconfig.spec.json │ ├── main.ts │ ├── global.scss │ ├── test.ts │ ├── index.html │ ├── karma.conf.js │ ├── theme │ │ └── variables.scss │ └── polyfills.ts ├── android │ ├── app │ │ ├── .npmignore │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── drawable │ │ │ │ │ │ ├── splash.png │ │ │ │ │ │ ├── launch_splash.xml │ │ │ │ │ │ └── ic_launcher_background.xml │ │ │ │ │ ├── drawable-land-hdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-land-mdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-port-hdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-port-mdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── drawable-land-xhdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-land-xxhdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-port-xhdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-port-xxhdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ ├── ic_launcher_round.png │ │ │ │ │ │ └── ic_launcher_foreground.png │ │ │ │ │ ├── drawable-land-xxxhdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── drawable-port-xxxhdpi │ │ │ │ │ │ └── splash.png │ │ │ │ │ ├── values │ │ │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── xml │ │ │ │ │ │ ├── file_paths.xml │ │ │ │ │ │ └── config.xml │ │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ │ ├── layout │ │ │ │ │ │ └── activity_main.xml │ │ │ │ │ └── drawable-v24 │ │ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── java │ │ │ │ │ └── io │ │ │ │ │ │ └── capacitor │ │ │ │ │ │ └── starter │ │ │ │ │ │ └── MainActivity.java │ │ │ │ ├── assets │ │ │ │ │ ├── capacitor.plugins.json │ │ │ │ │ └── capacitor.config.json │ │ │ │ └── AndroidManifest.xml │ │ │ ├── test │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── getcapacitor │ │ │ │ │ └── myapp │ │ │ │ │ └── ExampleUnitTest.java │ │ │ └── androidTest │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── getcapacitor │ │ │ │ └── myapp │ │ │ │ └── ExampleInstrumentedTest.java │ │ ├── capacitor.build.gradle │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── capacitor.settings.gradle │ ├── build.gradle │ ├── gradle.properties │ ├── .gitignore │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── App │ │ ├── App │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ ├── Splash.imageset │ │ │ │ │ ├── splash-2732x2732.png │ │ │ │ │ ├── splash-2732x2732-1.png │ │ │ │ │ ├── splash-2732x2732-2.png │ │ │ │ │ └── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ ├── AppIcon-512@2x.png │ │ │ │ │ ├── AppIcon-20x20@1x.png │ │ │ │ │ ├── AppIcon-20x20@2x-1.png │ │ │ │ │ ├── AppIcon-20x20@2x.png │ │ │ │ │ ├── AppIcon-20x20@3x.png │ │ │ │ │ ├── AppIcon-29x29@1x.png │ │ │ │ │ ├── AppIcon-29x29@2x-1.png │ │ │ │ │ ├── AppIcon-29x29@2x.png │ │ │ │ │ ├── AppIcon-29x29@3x.png │ │ │ │ │ ├── AppIcon-40x40@1x.png │ │ │ │ │ ├── AppIcon-40x40@2x-1.png │ │ │ │ │ ├── AppIcon-40x40@2x.png │ │ │ │ │ ├── AppIcon-40x40@3x.png │ │ │ │ │ ├── AppIcon-60x60@2x.png │ │ │ │ │ ├── AppIcon-60x60@3x.png │ │ │ │ │ ├── AppIcon-76x76@1x.png │ │ │ │ │ ├── AppIcon-76x76@2x.png │ │ │ │ │ ├── AppIcon-83.5x83.5@2x.png │ │ │ │ │ └── Contents.json │ │ │ ├── config.xml │ │ │ ├── App.entitlements │ │ │ ├── capacitor.config.json │ │ │ ├── Base.lproj │ │ │ │ ├── Main.storyboard │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── Info.plist │ │ │ └── AppDelegate.swift │ │ ├── App.xcodeproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── App.xcscheme │ │ ├── App.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ ├── Podfile │ │ └── Podfile.lock │ └── .gitignore ├── ionic.config.json ├── e2e │ ├── src │ │ ├── app.po.ts │ │ └── app.e2e-spec.ts │ ├── tsconfig.e2e.json │ └── protractor.conf.js ├── README.md ├── capacitor.config.json ├── tsconfig.json ├── ionic.starter.json ├── .gitignore ├── tslint.json ├── package.json └── angular.json ├── .eslintignore ├── CONTRIBUTING.md ├── .github ├── CODEOWNERS └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── CODE_OF_CONDUCT.md ├── ios ├── Plugin.xcworkspace │ └── contents.xcworkspacedata ├── Plugin │ ├── Plugin.h │ ├── Plugin.m │ ├── Info.plist │ └── Plugin.swift ├── Podfile └── PluginTests │ ├── Info.plist │ └── PluginTests.swift ├── src ├── index.ts ├── web.ts └── definitions.ts ├── rollup.config.mjs ├── tsconfig.json ├── CapacitorCommunityFcm.podspec ├── LICENSE ├── .gitignore ├── Package.swift ├── package.json ├── .all-contributorsrc ├── CHANGELOG.md └── README.md /.prettierignore: -------------------------------------------------------------------------------- 1 | example -------------------------------------------------------------------------------- /android/.npmignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example/.gradle/4.10.1/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | example -------------------------------------------------------------------------------- /example/src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /example/.gradle/4.10.1/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/.gradle/4.10.1/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- 1 | %tņ% Oh -------------------------------------------------------------------------------- /example/android/app/.npmignore: -------------------------------------------------------------------------------- 1 | /build/* 2 | !/build/.npmkeep 3 | -------------------------------------------------------------------------------- /example/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /example/.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Mon Jun 29 10:44:01 BRT 2020 2 | gradle.version=4.10.1 3 | -------------------------------------------------------------------------------- /example/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 2 | -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /example/src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':capacitor-android' 2 | project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "capacitor-fcm-demo", 3 | "integrations": { 4 | "capacitor": {} 5 | }, 6 | "type": "angular" 7 | } 8 | -------------------------------------------------------------------------------- /example/.gradle/4.10.1/taskHistory/taskHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/.gradle/4.10.1/taskHistory/taskHistory.lock -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable/splash.png -------------------------------------------------------------------------------- /example/.gradle/buildOutputCleanup/buildOutputCleanup.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/.gradle/buildOutputCleanup/buildOutputCleanup.lock -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-land-hdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-land-hdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-land-mdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-land-mdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-port-hdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-port-hdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-port-mdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-port-mdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-land-xhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-land-xhdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-land-xxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-land-xxhdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-port-xhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-port-xhdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-port-xxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-port-xxhdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-land-xxxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-land-xxxhdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-port-xxxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/drawable-port-xxxhdpi/splash.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /example/src/zone-flags.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Prevents Angular change detection from 3 | * running with certain Web Component callbacks 4 | */ 5 | (window as any).__Zone_disable_customElements = true; 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Please see [`CODE_OF_CONDUCT.md`](https://github.com/capacitor-community/welcome/blob/main/CODE_OF_CONDUCT.md) in the Capacitor Community Welcome repository. 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png -------------------------------------------------------------------------------- /example/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: 'app.component.html', 6 | }) 7 | export class AppComponent {} 8 | -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capacitor-community/fcm/HEAD/example/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/xml/file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /example/ios/App/App/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/xml/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | include ':capacitor-cordova-android-plugins' 3 | project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') 4 | 5 | apply from: 'capacitor.settings.gradle' -------------------------------------------------------------------------------- /example/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [], 6 | "skipLibCheck": true 7 | }, 8 | "exclude": ["test.ts", "**/*.spec.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /example/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.deepCss('app-root ion-content')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jan 30 13:14:22 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip 7 | -------------------------------------------------------------------------------- /example/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/App/App/App.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Plugin.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/App/App.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/io/capacitor/starter/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.capacitor.starter; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.getcapacitor.BridgeActivity; 6 | import com.getcapacitor.Plugin; 7 | 8 | import java.util.ArrayList; 9 | 10 | public class MainActivity extends BridgeActivity {} 11 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | # NPM renames .gitignore to .npmignore 2 | # In order to prevent that, we remove the initial "." 3 | # And the CLI then renames it 4 | 5 | App/build 6 | App/Pods 7 | App/public 8 | App/App/public 9 | xcuserdata 10 | 11 | # Cordova plugins for Capacitor 12 | capacitor-cordova-ios-plugins 13 | DerivedData 14 | -------------------------------------------------------------------------------- /example/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/assets/capacitor.plugins.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "pkg": "@capacitor-community/fcm", 4 | "classpath": "com.getcapacitor.community.fcm.FCMPlugin" 5 | }, 6 | { 7 | "pkg": "@capacitor/push-notifications", 8 | "classpath": "com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # quick start for ios 2 | 3 | - `git clone https://github.com/capacitor-community/fcm` 4 | - `cd fcm/example && npm install` 5 | - add your `GoogleService-Info.plist` to `ios/App/App` 6 | - `npm run start` 7 | 8 | ![capacitor fcm demo](https://user-images.githubusercontent.com/719763/60686663-8cfe7680-9e80-11e9-996c-4a57ad2393c7.gif) 9 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { registerPlugin } from '@capacitor/core'; 2 | 3 | import type { FCMPlugin } from './definitions'; 4 | 5 | const FCM = registerPlugin('FCM', { 6 | web: () => import('./web').then((m) => new m.FCMWeb()), 7 | }); 8 | 9 | // export * from './web'; // @todo 10 | export * from './definitions'; 11 | export { FCM }; 12 | -------------------------------------------------------------------------------- /example/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "page", 15 | "kebab-case" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/ios/App/App/capacitor.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "appId": "io.capacitor.starter", 3 | "appName": "capacitor-fcm-demo", 4 | "bundledWebRuntime": false, 5 | "npmClient": "npm", 6 | "webDir": "www", 7 | "plugins": { 8 | "PushNotifications": { 9 | "presentationOptions": [ 10 | "badge", 11 | "sound", 12 | "alert" 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('new App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should be blank', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toContain('The world is your oyster.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /example/android/app/src/main/assets/capacitor.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "appId": "io.capacitor.starter", 3 | "appName": "capacitor-fcm-demo", 4 | "bundledWebRuntime": false, 5 | "npmClient": "npm", 6 | "webDir": "www", 7 | "plugins": { 8 | "PushNotifications": { 9 | "presentationOptions": [ 10 | "badge", 11 | "sound", 12 | "alert" 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/capacitor.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "appId": "io.capacitor.starter", 3 | "appName": "capacitor-fcm-demo", 4 | "bundledWebRuntime": false, 5 | "npmClient": "npm", 6 | "webDir": "www", 7 | "plugins": { 8 | "PushNotifications": { 9 | "presentationOptions": [ 10 | "badge", 11 | "sound", 12 | "alert" 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "zone-flags.ts", 13 | "polyfills.ts" 14 | ], 15 | "include": [ 16 | "**/*.spec.ts", 17 | "**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /ios/Plugin/Plugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for Plugin. 4 | FOUNDATION_EXPORT double PluginVersionNumber; 5 | 6 | //! Project version string for Plugin. 7 | FOUNDATION_EXPORT const unsigned char PluginVersionString[]; 8 | 9 | // In this header, you should import all the public headers of your framework using statements like #import 10 | 11 | -------------------------------------------------------------------------------- /example/src/app/app.scss: -------------------------------------------------------------------------------- 1 | // App Styles 2 | // ---------------------------------------------------------------------------- 3 | // Put style rules here that you want to apply to the entire application. These 4 | // styles are for the entire app and not just one component. Additionally, this 5 | // file can hold Sass mixins, functions, and placeholder classes to be imported 6 | // and used throughout the application. -------------------------------------------------------------------------------- /example/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | capacitor-fcm-demo 4 | capacitor-fcm-demo 5 | io.capacitor.starter 6 | io.capacitor.starter.fileprovider 7 | io.capacitor.starter 8 | 9 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": ["node_modules/@types"], 15 | "lib": ["es2018", "dom"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/ionic.starter.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Blank Starter", 3 | "baseref": "master", 4 | "tarignore": [ 5 | "node_modules", 6 | "package-lock.json", 7 | "www" 8 | ], 9 | "scripts": { 10 | "test": "npm run lint && npm run ng -- build --configuration=ci && npm run ng -- build --prod --progress=false && npm run ng -- test --configuration=ci && npm run ng -- e2e --configuration=ci && npm run ng -- g pg my-page --dry-run && npm run ng -- g c my-component --dry-run" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /android/src/test/java/com/getcapacitor/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | 14 | @Test 15 | public void addition_isCorrect() throws Exception { 16 | assertEquals(4, 2 + 2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor.myapp; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/android/capacitor.settings.gradle: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN 2 | include ':capacitor-android' 3 | project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') 4 | 5 | include ':capacitor-community-fcm' 6 | project(':capacitor-community-fcm').projectDir = new File('../../android') 7 | 8 | include ':capacitor-push-notifications' 9 | project(':capacitor-push-notifications').projectDir = new File('../node_modules/@capacitor/push-notifications/android') 10 | -------------------------------------------------------------------------------- /rollup.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | input: 'dist/esm/index.js', 3 | output: [ 4 | { 5 | file: 'dist/plugin.js', 6 | format: 'iife', 7 | name: 'capacitorPlugin', 8 | globals: { 9 | '@capacitor/core': 'capacitorExports', 10 | }, 11 | sourcemap: true, 12 | inlineDynamicImports: true, 13 | }, 14 | { 15 | file: 'dist/plugin.cjs.js', 16 | format: 'cjs', 17 | sourcemap: true, 18 | inlineDynamicImports: true, 19 | }, 20 | ], 21 | external: ['@capacitor/core'], 22 | }; -------------------------------------------------------------------------------- /example/src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | Ionic Blank 3 | 4 | 5 | 6 |
7 | Subscribe 8 | 9 | Unsubscribe 10 | 11 | Get token 12 | {{ remoteToken }} 13 | 14 |
15 | Notifications: 16 |
17 | {{ notifications | json }} 18 |
19 | -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "splash-2732x2732-2.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "splash-2732x2732-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "splash-2732x2732.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowUnreachableCode": false, 4 | "declaration": true, 5 | "esModuleInterop": true, 6 | "inlineSources": true, 7 | "lib": ["dom", "es2017"], 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "noFallthroughCasesInSwitch": true, 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "outDir": "dist/esm", 14 | "pretty": true, 15 | "sourceMap": true, 16 | "strict": true, 17 | "target": "es2017" 18 | }, 19 | "files": ["src/index.ts"] 20 | } -------------------------------------------------------------------------------- /example/src/global.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/theming/ 2 | @import '~@ionic/angular/css/core.css'; 3 | @import '~@ionic/angular/css/normalize.css'; 4 | @import '~@ionic/angular/css/structure.css'; 5 | @import '~@ionic/angular/css/typography.css'; 6 | @import '~@ionic/angular/css/display.css'; 7 | @import '~@ionic/angular/css/padding.css'; 8 | @import '~@ionic/angular/css/float-elements.css'; 9 | @import '~@ionic/angular/css/text-alignment.css'; 10 | @import '~@ionic/angular/css/text-transformation.css'; 11 | @import '~@ionic/angular/css/flex-utils.css'; 12 | -------------------------------------------------------------------------------- /example/android/app/capacitor.build.gradle: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN 2 | 3 | android { 4 | compileOptions { 5 | sourceCompatibility JavaVersion.VERSION_1_8 6 | targetCompatibility JavaVersion.VERSION_1_8 7 | } 8 | } 9 | 10 | apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" 11 | dependencies { 12 | implementation project(':capacitor-community-fcm') 13 | implementation project(':capacitor-push-notifications') 14 | 15 | } 16 | 17 | 18 | if (hasProperty('postBuildExtras')) { 19 | postBuildExtras() 20 | } 21 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | platform :ios, '14.0' 3 | 4 | def capacitor_pods 5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | pod 'Capacitor', :path => '../node_modules/@capacitor/ios' 8 | pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios' 9 | end 10 | 11 | target 'Plugin' do 12 | # Pods for IonicRunner 13 | pod 'FirebaseMessaging', '~> 11' 14 | capacitor_pods 15 | end 16 | 17 | target 'PluginTests' do 18 | pod 'FirebaseMessaging', '~> 11' 19 | capacitor_pods 20 | end 21 | -------------------------------------------------------------------------------- /example/src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { IonicModule } from '@ionic/angular'; 4 | import { FormsModule } from '@angular/forms'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | import { HomePage } from './home.page'; 8 | 9 | @NgModule({ 10 | imports: [ 11 | CommonModule, 12 | FormsModule, 13 | IonicModule, 14 | RouterModule.forChild([ 15 | { 16 | path: '', 17 | component: HomePage 18 | } 19 | ]) 20 | ], 21 | declarations: [HomePage] 22 | }) 23 | export class HomePageModule {} 24 | -------------------------------------------------------------------------------- /example/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from "@angular/core"; 2 | import { PreloadAllModules, RouterModule, Routes } from "@angular/router"; 3 | 4 | const routes: Routes = [ 5 | { path: "", redirectTo: "home", pathMatch: "full" }, 6 | 7 | { 8 | path: "home", 9 | loadChildren: () => 10 | import("./home/home.module").then((m) => m.HomePageModule), 11 | }, 12 | ]; 13 | 14 | @NgModule({ 15 | imports: [ 16 | RouterModule.forRoot(routes, { 17 | preloadingStrategy: PreloadAllModules, 18 | relativeLinkResolution: "legacy", 19 | }), 20 | ], 21 | exports: [RouterModule], 22 | }) 23 | export class AppRoutingModule {} 24 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .ionic/ 17 | .sourcemaps/ 18 | .sass-cache/ 19 | .tmp/ 20 | .versions/ 21 | coverage/ 22 | www/ 23 | node_modules/ 24 | tmp/ 25 | temp/ 26 | platforms/ 27 | plugins/ 28 | plugins/android.json 29 | plugins/ios.json 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | ios/App/App/GoogleService-Info.plist 36 | android/app/google-services.json 37 | -------------------------------------------------------------------------------- /CapacitorCommunityFcm.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = 'CapacitorCommunityFcm' 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.license = package['license'] 10 | s.homepage = package['repository']['url'] 11 | s.author = package['author'] 12 | s.source = { git: package['repository']['url'], tag: s.version.to_s } 13 | s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}' 14 | s.ios.deployment_target = '14.0' 15 | s.dependency 'Capacitor' 16 | s.dependency 'FirebaseMessaging' 17 | s.swift_version = '5.1' 18 | s.static_framework = true 19 | end -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /example/ios/App/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '12.0' 2 | use_frameworks! 3 | 4 | # workaround to avoid Xcode 10 caching of Pods that requires 5 | # Product -> Clean Build Folder after new Cordova plugins installed 6 | # Requires CocoaPods 1.6 or newer 7 | # install! 'cocoapods', :disable_input_output_paths => true 8 | 9 | def capacitor_pods 10 | pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' 11 | pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' 12 | pod 'CapacitorCommunityFcm', :path => '../../..' 13 | pod 'CapacitorPushNotifications', :path => '../../node_modules/@capacitor/push-notifications' 14 | end 15 | 16 | target 'App' do 17 | capacitor_pods 18 | # Add your Pods here 19 | end 20 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:7.0.2' 11 | classpath 'com.google.gms:google-services:4.3.8' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /example/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /example/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /example/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ionic App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ios/PluginTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /example/src/app/home/home.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; 3 | 4 | import { HomePage } from './home.page'; 5 | 6 | describe('HomePage', () => { 7 | let component: HomePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(waitForAsync(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ HomePage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(HomePage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /ios/Plugin/Plugin.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | // Define the plugin using the CAP_PLUGIN Macro, and 5 | // each method the plugin supports using the CAP_PLUGIN_METHOD macro. 6 | CAP_PLUGIN(FCMPlugin, "FCM", 7 | CAP_PLUGIN_METHOD(subscribeTo, CAPPluginReturnPromise); 8 | CAP_PLUGIN_METHOD(unsubscribeFrom, CAPPluginReturnPromise); 9 | CAP_PLUGIN_METHOD(getToken, CAPPluginReturnPromise); 10 | CAP_PLUGIN_METHOD(refreshToken, CAPPluginReturnPromise); 11 | CAP_PLUGIN_METHOD(deleteInstance, CAPPluginReturnPromise); 12 | CAP_PLUGIN_METHOD(setAutoInit, CAPPluginReturnPromise); 13 | CAP_PLUGIN_METHOD(isAutoInitEnabled, CAPPluginReturnPromise); 14 | CAP_PLUGIN_METHOD(refreshToken, CAPPluginReturnPromise); 15 | ) 16 | -------------------------------------------------------------------------------- /android/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /example/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouteReuseStrategy } from '@angular/router'; 4 | 5 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 6 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 7 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 8 | 9 | import { AppComponent } from './app.component'; 10 | import { AppRoutingModule } from './app-routing.module'; 11 | 12 | @NgModule({ 13 | declarations: [AppComponent], 14 | entryComponents: [], 15 | imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], 16 | providers: [ 17 | StatusBar, 18 | SplashScreen, 19 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } 20 | ], 21 | bootstrap: [AppComponent] 22 | }) 23 | export class AppModule {} 24 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true -------------------------------------------------------------------------------- /ios/Plugin/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /example/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor.myapp; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.getcapacitor.app", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 17 | 18 | 19 | 22 | -------------------------------------------------------------------------------- /android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor.android; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import android.content.Context; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | import androidx.test.platform.app.InstrumentationRegistry; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * @see Testing documentation 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | public class ExampleInstrumentedTest { 18 | 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | 24 | assertEquals("com.getcapacitor.android", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | # AndroidX package structure to make it clearer which packages are bundled with the 20 | # Android operating system, and which are packaged with your app's APK 21 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 22 | android.useAndroidX=true 23 | -------------------------------------------------------------------------------- /example/ios/App/App/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /example/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Stewan Silva 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example/src/assets/shapes.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/web.ts: -------------------------------------------------------------------------------- 1 | import { WebPlugin } from '@capacitor/core'; 2 | 3 | import type { FCMPlugin } from './definitions'; 4 | 5 | export class FCMWeb extends WebPlugin implements FCMPlugin { 6 | constructor() { 7 | super(); 8 | } 9 | 10 | subscribeTo(_options: { topic: string }): Promise<{ message: string }> { 11 | throw this.unimplemented('Not implemented on web.'); 12 | } 13 | 14 | unsubscribeFrom(_options: { topic: string }): Promise<{ message: string }> { 15 | throw this.unimplemented('Not implemented on web.'); 16 | } 17 | 18 | getToken(): Promise<{ token: string }> { 19 | throw this.unimplemented('Not implemented on web.'); 20 | } 21 | 22 | deleteInstance(): Promise { 23 | throw this.unimplemented('Not implemented on web.'); 24 | } 25 | 26 | setAutoInit(_options: { enabled: boolean }): Promise { 27 | throw this.unimplemented('Not implemented on web.'); 28 | } 29 | 30 | isAutoInitEnabled(): Promise<{ enabled: boolean }> { 31 | throw this.unimplemented('Not implemented on web.'); 32 | } 33 | 34 | refreshToken(): Promise<{ token: string }> { 35 | throw this.unimplemented('Not implemented on web.'); 36 | } 37 | } 38 | 39 | const FCM = new FCMWeb(); 40 | 41 | export { FCM }; 42 | -------------------------------------------------------------------------------- /ios/PluginTests/PluginTests.swift: -------------------------------------------------------------------------------- 1 | // import XCTest 2 | // import Capacitor 3 | // @testable import Plugin 4 | // 5 | // class PluginTests: XCTestCase { 6 | // 7 | // override func setUp() { 8 | // super.setUp() 9 | // // Put setup code here. This method is called before the invocation of each test method in the class. 10 | // } 11 | // 12 | // override func tearDown() { 13 | // // Put teardown code here. This method is called after the invocation of each test method in the class. 14 | // super.tearDown() 15 | // } 16 | // 17 | // func testEcho() { 18 | // // This is an example of a functional test case for a plugin. 19 | // // Use XCTAssert and related functions to verify your tests produce the correct results. 20 | // 21 | // let value = "Hello, World!" 22 | // let plugin = MyPlugin() 23 | // 24 | // let call = CAPPluginCall(callbackId: "test", options: [ 25 | // "value": value 26 | // ], success: { (result, call) in 27 | // let resultValue = result!.data["value"] as? String 28 | // XCTAssertEqual(value, resultValue) 29 | // }, error: { (err) in 30 | // XCTFail("Error shouldn't have been called") 31 | // }) 32 | // 33 | // plugin.echo(call!) 34 | // } 35 | // } 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # node files 2 | dist 3 | node_modules 4 | 5 | # iOS files 6 | Pods 7 | Podfile.lock 8 | Package.resolved 9 | Build 10 | xcuserdata 11 | /.build 12 | /Packages 13 | xcuserdata/ 14 | DerivedData/ 15 | .swiftpm/configuration/registries.json 16 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 17 | .netrc 18 | 19 | 20 | # macOS files 21 | .DS_Store 22 | 23 | package-lock.json 24 | 25 | # Based on Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore 26 | 27 | # Built application files 28 | *.apk 29 | *.ap_ 30 | 31 | # Files for the ART/Dalvik VM 32 | *.dex 33 | 34 | # Java class files 35 | *.class 36 | 37 | # Generated files 38 | bin 39 | gen 40 | out 41 | 42 | # Gradle files 43 | .gradle 44 | build 45 | 46 | # Local configuration file (sdk path, etc) 47 | local.properties 48 | 49 | # Proguard folder generated by Eclipse 50 | proguard 51 | 52 | # Log Files 53 | *.log 54 | 55 | # Android Studio Navigation editor temp files 56 | .navigation 57 | 58 | # Android Studio captures folder 59 | captures 60 | 61 | # IntelliJ 62 | *.iml 63 | .idea 64 | 65 | # Keystore files 66 | # Uncomment the following line if you do not want to check your keystore files in. 67 | #*.jks 68 | 69 | # External native build folder generated in Android Studio 2.2 and later 70 | .externalNativeBuild -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.9 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "CapacitorCommunityFcm", 6 | platforms: [.iOS(.v14)], 7 | products: [ 8 | .library( 9 | name: "CapacitorCommunityFcm", 10 | targets: ["CapacitorCommunityFcmC", "CapacitorCommunityFcmSwift"]) 11 | ], 12 | dependencies: [ 13 | .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"), 14 | .package(url: "https://github.com/firebase/firebase-ios-sdk.git", "11.6.0"..<"12.0.0"), 15 | ], 16 | targets: [ 17 | .target( 18 | name: "CapacitorCommunityFcmC", 19 | dependencies: [ 20 | .product(name: "Capacitor", package: "capacitor-swift-pm") 21 | ], 22 | path: "ios/Plugin", 23 | sources: [ 24 | "Plugin.h", 25 | "Plugin.m" 26 | ], 27 | publicHeadersPath: "." 28 | ), 29 | .target( 30 | name: "CapacitorCommunityFcmSwift", 31 | dependencies: [ 32 | .product(name: "Capacitor", package: "capacitor-swift-pm"), 33 | .product(name: "FirebaseMessaging", package: "firebase-ios-sdk") 34 | ], 35 | path: "ios/Plugin", 36 | sources: [ 37 | "Plugin.swift" 38 | ] 39 | ), 40 | .testTarget( 41 | name: "CapacitorCommunityFcmTests", 42 | dependencies: ["CapacitorCommunityFcmSwift"], 43 | path: "ios/PluginTests" 44 | ) 45 | ] 46 | ) 47 | -------------------------------------------------------------------------------- /src/definitions.ts: -------------------------------------------------------------------------------- 1 | export interface FCMPlugin { 2 | /** 3 | * Subscribe to fcm topic 4 | * @param options 5 | */ 6 | subscribeTo(options: { topic: string }): Promise<{ message: string }>; 7 | 8 | /** 9 | * Unsubscribe from fcm topic 10 | * @param options 11 | */ 12 | unsubscribeFrom(options: { topic: string }): Promise<{ message: string }>; 13 | 14 | /** 15 | * Get fcm token to eventually use from a serve 16 | * 17 | * Recommended to use this instead of 18 | * @usage 19 | * ```typescript 20 | * PushNotifications.addListener("registration", (token) => { 21 | * console.log(token.data); 22 | * }); 23 | * ``` 24 | * because the native capacitor method, for apple, returns the APN's token 25 | */ 26 | getToken(): Promise<{ token: string }>; 27 | 28 | /** 29 | * Refresh fcm token to eventually use from a serve 30 | * 31 | * Recommended to use this instead of 32 | * @usage 33 | * ```typescript 34 | * PushNotifications.addListener("registration", (token) => { 35 | * console.log(token.data); 36 | * }); 37 | * ``` 38 | * because the native capacitor method, for apple, returns the APN's token 39 | */ 40 | refreshToken(): Promise<{ token: string }>; 41 | 42 | /** 43 | * Remove local fcm instance completely 44 | */ 45 | deleteInstance(): Promise; 46 | 47 | /** 48 | * Enabled/disabled auto initialization. 49 | * @param options 50 | */ 51 | setAutoInit(options: { enabled: boolean }): Promise; 52 | 53 | /** 54 | * Retrieve the auto initialization status. 55 | */ 56 | isAutoInitEnabled(): Promise<{ enabled: boolean }>; 57 | } 58 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | defaultConfig { 6 | applicationId "io.capacitor.starter" 7 | minSdkVersion 21 8 | targetSdkVersion 30 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | repositories { 22 | maven { 23 | url "https://dl.bintray.com/ionic-team/capacitor" 24 | } 25 | flatDir{ 26 | dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(include: ['*.jar'], dir: 'libs') 32 | implementation 'com.android.support:appcompat-v7:28.0.0' 33 | implementation project(':capacitor-android') 34 | testImplementation 'junit:junit:4.12' 35 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 37 | implementation project(':capacitor-cordova-android-plugins') 38 | implementation "androidx.appcompat:appcompat:1.2.0-alpha02" 39 | } 40 | 41 | apply from: 'capacitor.build.gradle' 42 | 43 | try { 44 | def servicesJSON = file('google-services.json') 45 | if (servicesJSON.text) { 46 | apply plugin: 'com.google.gms.google-services' 47 | } 48 | } catch(Exception e) { 49 | logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work") 50 | } -------------------------------------------------------------------------------- /example/ios/App/App/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /example/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { TestBed, waitForAsync } from '@angular/core/testing'; 3 | 4 | import { Platform } from '@ionic/angular'; 5 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 6 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | describe('AppComponent', () => { 11 | 12 | let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; 13 | 14 | beforeEach(waitForAsync(() => { 15 | statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); 16 | splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); 17 | platformReadySpy = Promise.resolve(); 18 | platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); 19 | 20 | TestBed.configureTestingModule({ 21 | declarations: [AppComponent], 22 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 23 | providers: [ 24 | { provide: StatusBar, useValue: statusBarSpy }, 25 | { provide: SplashScreen, useValue: splashScreenSpy }, 26 | { provide: Platform, useValue: platformSpy }, 27 | ], 28 | }).compileComponents(); 29 | })); 30 | 31 | it('should create the app', () => { 32 | const fixture = TestBed.createComponent(AppComponent); 33 | const app = fixture.debugElement.componentInstance; 34 | expect(app).toBeTruthy(); 35 | }); 36 | 37 | it('should initialize the app', async () => { 38 | TestBed.createComponent(AppComponent); 39 | expect(platformSpy.ready).toHaveBeenCalled(); 40 | await platformReadySpy; 41 | expect(statusBarSpy.styleDefault).toHaveBeenCalled(); 42 | expect(splashScreenSpy.hide).toHaveBeenCalled(); 43 | }); 44 | 45 | // TODO: add more tests! 46 | 47 | }); 48 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | # NPM renames .gitignore to .npmignore 2 | # In order to prevent that, we remove the initial "." 3 | # And the CLI then renames it 4 | 5 | # Using Android gitignore template: https://github.com/github/gitignore/blob/master/Android.gitignore 6 | 7 | # Built application files 8 | *.apk 9 | *.ap_ 10 | *.aab 11 | 12 | # Files for the ART/Dalvik VM 13 | *.dex 14 | 15 | # Java class files 16 | *.class 17 | 18 | # Generated files 19 | bin/ 20 | gen/ 21 | out/ 22 | release/ 23 | 24 | # Gradle files 25 | .gradle/ 26 | build/ 27 | 28 | # Local configuration file (sdk path, etc) 29 | local.properties 30 | 31 | # Proguard folder generated by Eclipse 32 | proguard/ 33 | 34 | # Log Files 35 | *.log 36 | 37 | # Android Studio Navigation editor temp files 38 | .navigation/ 39 | 40 | # Android Studio captures folder 41 | captures/ 42 | 43 | # IntelliJ 44 | *.iml 45 | .idea/workspace.xml 46 | .idea/tasks.xml 47 | .idea/gradle.xml 48 | .idea/assetWizardSettings.xml 49 | .idea/dictionaries 50 | .idea/libraries 51 | # Android Studio 3 in .gitignore file. 52 | .idea/caches 53 | .idea/modules.xml 54 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 55 | .idea/navEditor.xml 56 | 57 | # Keystore files 58 | # Uncomment the following lines if you do not want to check your keystore files in. 59 | #*.jks 60 | #*.keystore 61 | 62 | # External native build folder generated in Android Studio 2.2 and later 63 | .externalNativeBuild 64 | 65 | # Freeline 66 | freeline.py 67 | freeline/ 68 | freeline_project_description.json 69 | 70 | # fastlane 71 | fastlane/report.xml 72 | fastlane/Preview.html 73 | fastlane/screenshots 74 | fastlane/test_output 75 | fastlane/readme.md 76 | 77 | # Version control 78 | vcs.xml 79 | 80 | # lint 81 | lint/intermediates/ 82 | lint/generated/ 83 | lint/outputs/ 84 | lint/tmp/ 85 | # lint/reports/ 86 | 87 | # Cordova plugins for Capacitor 88 | capacitor-cordova-android-plugins 89 | 90 | # Copied web assets 91 | app/src/main/assets/public 92 | -------------------------------------------------------------------------------- /example/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "array-type": false, 8 | "arrow-parens": false, 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "import-blacklist": [ 13 | true, 14 | "rxjs/Rx" 15 | ], 16 | "interface-name": false, 17 | "max-classes-per-file": false, 18 | "max-line-length": [ 19 | true, 20 | 140 21 | ], 22 | "member-access": false, 23 | "member-ordering": [ 24 | true, 25 | { 26 | "order": [ 27 | "static-field", 28 | "instance-field", 29 | "static-method", 30 | "instance-method" 31 | ] 32 | } 33 | ], 34 | "no-consecutive-blank-lines": false, 35 | "no-console": [ 36 | true, 37 | "debug", 38 | "info", 39 | "time", 40 | "timeEnd", 41 | "trace" 42 | ], 43 | "no-empty": false, 44 | "no-inferrable-types": [ 45 | true, 46 | "ignore-params" 47 | ], 48 | "no-non-null-assertion": true, 49 | "no-redundant-jsdoc": true, 50 | "no-switch-case-fall-through": true, 51 | "no-use-before-declare": true, 52 | "no-var-requires": false, 53 | "object-literal-key-quotes": [ 54 | true, 55 | "as-needed" 56 | ], 57 | "object-literal-sort-keys": false, 58 | "ordered-imports": false, 59 | "quotemark": [ 60 | true, 61 | "single" 62 | ], 63 | "trailing-comma": false, 64 | "no-output-on-prefix": true, 65 | "use-input-property-decorator": true, 66 | "use-output-property-decorator": true, 67 | "use-host-property-decorator": true, 68 | "no-input-rename": true, 69 | "no-output-rename": true, 70 | "use-life-cycle-interface": true, 71 | "use-pipe-transform-interface": true, 72 | "one-variable-per-declaration": false, 73 | "component-class-suffix": [true, "Page", "Component"], 74 | "directive-class-suffix": true 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /example/src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, NgZone } from '@angular/core'; 2 | import { Platform } from '@ionic/angular'; 3 | import { 4 | PushNotifications, 5 | PushNotificationSchema, 6 | } from '@capacitor/push-notifications'; 7 | import { FCM } from '@capacitor-community/fcm'; 8 | 9 | @Component({ 10 | selector: 'app-home', 11 | templateUrl: 'home.page.html', 12 | styleUrls: ['home.page.scss'], 13 | }) 14 | export class HomePage implements OnInit { 15 | session: any; 16 | 17 | notifications: PushNotificationSchema[] = []; 18 | 19 | topicName = 'super-awesome-topic'; 20 | remoteToken: string; 21 | 22 | constructor(private platform: Platform, private zone: NgZone) {} 23 | 24 | ngOnInit() { 25 | PushNotifications.addListener('registration', (data) => { 26 | // alert(JSON.stringify(data)); 27 | console.log(data); 28 | }); 29 | PushNotifications.addListener( 30 | 'pushNotificationReceived', 31 | (notification: PushNotificationSchema) => { 32 | console.log('notification ' + JSON.stringify(notification)); 33 | this.zone.run(() => { 34 | this.notifications.push(notification); 35 | }); 36 | } 37 | ); 38 | PushNotifications.requestPermissions().then((response) => 39 | PushNotifications.register().then(() => alert(`registered for push`)) 40 | ); 41 | } 42 | 43 | // move to fcm demo 44 | subscribeTo() { 45 | PushNotifications.register() 46 | .then((_) => { 47 | FCM.subscribeTo({ topic: this.topicName }) 48 | .then((r) => alert(`subscribed to topic ${this.topicName}`)) 49 | .catch((err) => console.log(err)); 50 | }) 51 | .catch((err) => alert(JSON.stringify(err))); 52 | } 53 | 54 | unsubscribeFrom() { 55 | FCM.unsubscribeFrom({ topic: this.topicName }) 56 | .then((r) => alert(`unsubscribed from topic ${this.topicName}`)) 57 | .catch((err) => console.log(err)); 58 | 59 | if (this.platform.is('android')) { 60 | FCM.deleteInstance(); 61 | } 62 | } 63 | 64 | getToken() { 65 | FCM.getToken() 66 | .then((result) => { 67 | this.remoteToken = result.token; 68 | }) 69 | .catch((err) => console.log(err)); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2' 3 | androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0' 4 | androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1' 5 | androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1' 6 | firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '24.1.0' 7 | } 8 | 9 | buildscript { 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | dependencies { 15 | classpath 'com.android.tools.build:gradle:8.7.2' 16 | } 17 | } 18 | 19 | apply plugin: 'com.android.library' 20 | 21 | android { 22 | namespace "com.getcapacitor.community.fcm.fcm" 23 | compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35 24 | defaultConfig { 25 | minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23 26 | targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35 27 | versionCode 1 28 | versionName "1.0" 29 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 30 | } 31 | buildTypes { 32 | release { 33 | minifyEnabled false 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 35 | } 36 | } 37 | lintOptions { 38 | abortOnError false 39 | } 40 | 41 | compileOptions { 42 | sourceCompatibility JavaVersion.VERSION_21 43 | targetCompatibility JavaVersion.VERSION_21 44 | } 45 | } 46 | 47 | repositories { 48 | google() 49 | mavenCentral() 50 | } 51 | 52 | 53 | dependencies { 54 | implementation fileTree(dir: 'libs', include: ['*.jar']) 55 | implementation project(':capacitor-android') 56 | implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" 57 | testImplementation "junit:junit:$junitVersion" 58 | androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" 59 | androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" 60 | implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion" 61 | } 62 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "capacitor-fcm-demo", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "https://ionicframework.com/", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "npm run serve:ios", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e", 13 | "upgrade:capacitor": "npx npm-upgrade '*capacitor*' && npm install", 14 | "serve:ios": "ionic cap run ios --livereload --address=0.0.0.0", 15 | "serve:android": "ionic cap run android --livereload --address=0.0.0.0" 16 | }, 17 | "private": true, 18 | "dependencies": { 19 | "@angular/common": "^12.0.4", 20 | "@angular/core": "^12.0.4", 21 | "@angular/forms": "^12.0.4", 22 | "@angular/http": "^7.2.2", 23 | "@angular/platform-browser": "^12.0.4", 24 | "@angular/platform-browser-dynamic": "^12.0.4", 25 | "@angular/router": "^12.0.4", 26 | "@capacitor-community/fcm": "../", 27 | "@capacitor/android": "^3.0.1", 28 | "@capacitor/cli": "^3.0.1", 29 | "@capacitor/core": "^3.0.1", 30 | "@capacitor/ios": "^3.0.1", 31 | "@capacitor/push-notifications": "^1.0.4", 32 | "@ionic-native/core": "^5.0.0", 33 | "@ionic-native/splash-screen": "^5.0.0", 34 | "@ionic-native/status-bar": "^5.0.0", 35 | "@ionic/angular": "^4.1.0", 36 | "core-js": "^2.5.4", 37 | "rxjs": "~6.5.1", 38 | "tslib": "^1.9.0", 39 | "zone.js": "~0.11.4" 40 | }, 41 | "devDependencies": { 42 | "@angular-devkit/architect": "~0.13.8", 43 | "@angular-devkit/build-angular": "~0.13.8", 44 | "@angular-devkit/core": "~7.3.8", 45 | "@angular-devkit/schematics": "~7.3.8", 46 | "@angular/cli": "~7.3.8", 47 | "@angular/compiler": "~12.0.4", 48 | "@angular/compiler-cli": "~12.0.4", 49 | "@angular/language-service": "~12.0.4", 50 | "@ionic/angular-toolkit": "~1.5.1", 51 | "@types/jasmine": "~2.8.8", 52 | "@types/jasminewd2": "~2.0.3", 53 | "@types/node": "~12.0.0", 54 | "codelyzer": "~4.5.0", 55 | "jasmine-core": "~2.99.1", 56 | "jasmine-spec-reporter": "~4.2.1", 57 | "jetifier": "^2.0.0", 58 | "karma": "~4.1.0", 59 | "karma-chrome-launcher": "~2.2.0", 60 | "karma-coverage-istanbul-reporter": "~2.0.1", 61 | "karma-jasmine": "~1.1.2", 62 | "karma-jasmine-html-reporter": "^0.2.2", 63 | "protractor": "~5.4.0", 64 | "ts-node": "~8.1.0", 65 | "tslint": "~5.17.0", 66 | "typescript": "~4.2.4" 67 | }, 68 | "description": "An Ionic project" 69 | } 70 | -------------------------------------------------------------------------------- /example/ios/App/App/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | FCM Demo App 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleURLTypes 22 | 23 | 24 | CFBundleURLName 25 | com.getcapacitor.capacitor 26 | CFBundleURLSchemes 27 | 28 | capacitor 29 | 30 | 31 | 32 | CFBundleVersion 33 | 1 34 | LSRequiresIPhoneOS 35 | 36 | NSAppTransportSecurity 37 | 38 | NSAllowsArbitraryLoads 39 | 40 | 41 | NSCameraUsageDescription 42 | To Take Photos and Video 43 | NSLocationAlwaysUsageDescription 44 | Always allow Geolocation? 45 | NSLocationWhenInUseUsageDescription 46 | Allow Geolocation? 47 | NSMicrophoneUsageDescription 48 | To Record Audio With Video 49 | NSPhotoLibraryAddUsageDescription 50 | Store camera photos to camera 51 | NSPhotoLibraryUsageDescription 52 | To Pick Photos from Library 53 | UIBackgroundModes 54 | 55 | remote-notification 56 | 57 | UILaunchStoryboardName 58 | LaunchScreen 59 | UIMainStoryboardFile 60 | Main 61 | UIRequiredDeviceCapabilities 62 | 63 | armv7 64 | 65 | UISupportedInterfaceOrientations 66 | 67 | UIInterfaceOrientationPortrait 68 | 69 | UISupportedInterfaceOrientations~ipad 70 | 71 | UIInterfaceOrientationPortrait 72 | UIInterfaceOrientationPortraitUpsideDown 73 | UIInterfaceOrientationLandscapeLeft 74 | UIInterfaceOrientationLandscapeRight 75 | 76 | UIViewControllerBasedStatusBarAppearance 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /example/src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | /** primary **/ 7 | --ion-color-primary: #3880ff; 8 | --ion-color-primary-rgb: 56, 128, 255; 9 | --ion-color-primary-contrast: #ffffff; 10 | --ion-color-primary-contrast-rgb: 255, 255, 255; 11 | --ion-color-primary-shade: #3171e0; 12 | --ion-color-primary-tint: #4c8dff; 13 | 14 | /** secondary **/ 15 | --ion-color-secondary: #0cd1e8; 16 | --ion-color-secondary-rgb: 12, 209, 232; 17 | --ion-color-secondary-contrast: #ffffff; 18 | --ion-color-secondary-contrast-rgb: 255, 255, 255; 19 | --ion-color-secondary-shade: #0bb8cc; 20 | --ion-color-secondary-tint: #24d6ea; 21 | 22 | /** tertiary **/ 23 | --ion-color-tertiary: #7044ff; 24 | --ion-color-tertiary-rgb: 112, 68, 255; 25 | --ion-color-tertiary-contrast: #ffffff; 26 | --ion-color-tertiary-contrast-rgb: 255, 255, 255; 27 | --ion-color-tertiary-shade: #633ce0; 28 | --ion-color-tertiary-tint: #7e57ff; 29 | 30 | /** success **/ 31 | --ion-color-success: #10dc60; 32 | --ion-color-success-rgb: 16, 220, 96; 33 | --ion-color-success-contrast: #ffffff; 34 | --ion-color-success-contrast-rgb: 255, 255, 255; 35 | --ion-color-success-shade: #0ec254; 36 | --ion-color-success-tint: #28e070; 37 | 38 | /** warning **/ 39 | --ion-color-warning: #ffce00; 40 | --ion-color-warning-rgb: 255, 206, 0; 41 | --ion-color-warning-contrast: #ffffff; 42 | --ion-color-warning-contrast-rgb: 255, 255, 255; 43 | --ion-color-warning-shade: #e0b500; 44 | --ion-color-warning-tint: #ffd31a; 45 | 46 | /** danger **/ 47 | --ion-color-danger: #f04141; 48 | --ion-color-danger-rgb: 245, 61, 61; 49 | --ion-color-danger-contrast: #ffffff; 50 | --ion-color-danger-contrast-rgb: 255, 255, 255; 51 | --ion-color-danger-shade: #d33939; 52 | --ion-color-danger-tint: #f25454; 53 | 54 | /** dark **/ 55 | --ion-color-dark: #222428; 56 | --ion-color-dark-rgb: 34, 34, 34; 57 | --ion-color-dark-contrast: #ffffff; 58 | --ion-color-dark-contrast-rgb: 255, 255, 255; 59 | --ion-color-dark-shade: #1e2023; 60 | --ion-color-dark-tint: #383a3e; 61 | 62 | /** medium **/ 63 | --ion-color-medium: #989aa2; 64 | --ion-color-medium-rgb: 152, 154, 162; 65 | --ion-color-medium-contrast: #ffffff; 66 | --ion-color-medium-contrast-rgb: 255, 255, 255; 67 | --ion-color-medium-shade: #86888f; 68 | --ion-color-medium-tint: #a2a4ab; 69 | 70 | /** light **/ 71 | --ion-color-light: #f4f5f8; 72 | --ion-color-light-rgb: 244, 244, 244; 73 | --ion-color-light-contrast: #000000; 74 | --ion-color-light-contrast-rgb: 0, 0, 0; 75 | --ion-color-light-shade: #d7d8da; 76 | --ion-color-light-tint: #f5f6f9; 77 | } 78 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /example/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "AppIcon-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "AppIcon-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "AppIcon-29x29@2x-1.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "AppIcon-29x29@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "AppIcon-40x40@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon-40x40@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "AppIcon-60x60@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "AppIcon-60x60@3x.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "20x20", 53 | "idiom" : "ipad", 54 | "filename" : "AppIcon-20x20@1x.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "AppIcon-20x20@2x-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "AppIcon-29x29@1x.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "AppIcon-29x29@2x.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon-40x40@1x.png", 79 | "scale" : "1x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "AppIcon-40x40@2x-1.png", 85 | "scale" : "2x" 86 | }, 87 | { 88 | "size" : "76x76", 89 | "idiom" : "ipad", 90 | "filename" : "AppIcon-76x76@1x.png", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "AppIcon-76x76@2x.png", 97 | "scale" : "2x" 98 | }, 99 | { 100 | "size" : "83.5x83.5", 101 | "idiom" : "ipad", 102 | "filename" : "AppIcon-83.5x83.5@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "1024x1024", 107 | "idiom" : "ios-marketing", 108 | "filename" : "AppIcon-512@2x.png", 109 | "scale" : "1x" 110 | } 111 | ], 112 | "info" : { 113 | "version" : 1, 114 | "author" : "xcode" 115 | } 116 | } -------------------------------------------------------------------------------- /example/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | import './zone-flags.ts'; 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | 61 | import 'zone.js/dist/zone'; // Included with Angular CLI. 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@capacitor-community/fcm", 3 | "version": "8.0.1", 4 | "description": "Enable Firebase Cloud Messaging features for Capacitor apps", 5 | "main": "dist/esm/index.js", 6 | "module": "dist/esm/index.js", 7 | "types": "dist/esm/index.d.ts", 8 | "unpkg": "dist/plugin.js", 9 | "files": [ 10 | "android/src/main", 11 | "android/build.gradle", 12 | "dist/", 13 | "ios/Plugin", 14 | "CapacitorCommunityFcm.podspec", 15 | "Package.swift" 16 | ], 17 | "author": "Stewan Silva", 18 | "license": "MIT", 19 | "homepage": "https://github.com/capacitor-community/fcm#readme", 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/capacitor-community/fcm.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/capacitor-community/fcm/issues" 26 | }, 27 | "keywords": [ 28 | "capacitor", 29 | "plugin", 30 | "native", 31 | "fcm", 32 | "firebase cloud messaging" 33 | ], 34 | "scripts": { 35 | "build": "npm run clean && tsc && rollup -c rollup.config.mjs", 36 | "clean": "rimraf ./dist", 37 | "watch": "tsc --watch", 38 | "prepublishOnly": "npm run build", 39 | "verify": "npm run verify:ios && npm run verify:android && npm run verify:web", 40 | "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..", 41 | "verify:android": "cd android && ./gradlew clean build test && cd ..", 42 | "verify:web": "npm run build", 43 | "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint", 44 | "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format", 45 | "eslint": "eslint . --ext ts", 46 | "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java", 47 | "swiftlint": "node-swiftlint", 48 | "release:patch": "standard-version release --release-as patch", 49 | "release:minor": "standard-version release --release-as minor", 50 | "release:major": "standard-version release --release-as major", 51 | "contributors:add": "all-contributors add", 52 | "contributors:gen": "all-contributors generate" 53 | }, 54 | "devDependencies": { 55 | "@capacitor/android": "^7.0.0", 56 | "@capacitor/core": "^7.0.0", 57 | "@capacitor/docgen": "^0.3.0", 58 | "@capacitor/ios": "^7.0.0", 59 | "@ionic/eslint-config": "^0.4.0", 60 | "@ionic/prettier-config": "^4.0.0", 61 | "@ionic/swiftlint-config": "^2.0.0", 62 | "all-contributors-cli": "^6.24.0", 63 | "eslint": "^8.57.0", 64 | "prettier": "^3.4.2", 65 | "prettier-plugin-java": "^2.6.6", 66 | "rimraf": "^6.0.1", 67 | "rollup": "^4.30.1", 68 | "standard-version": "^9.5.0", 69 | "swiftlint": "^2.0.0", 70 | "typescript": "~4.1.5" 71 | }, 72 | "peerDependencies": { 73 | "@capacitor/core": ">=7.0.0" 74 | }, 75 | "prettier": "@ionic/prettier-config", 76 | "swiftlint": "@ionic/swiftlint-config", 77 | "eslintConfig": { 78 | "extends": "@ionic/eslint-config/recommended" 79 | }, 80 | "capacitor": { 81 | "ios": { 82 | "src": "ios" 83 | }, 84 | "android": { 85 | "src": "android" 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /example/ios/App/App.xcodeproj/xcshareddata/xcschemes/App.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 68 | 69 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /example/ios/App/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Capacitor (3.2.4): 3 | - CapacitorCordova 4 | - CapacitorCommunityFcm (2.0.2): 5 | - Capacitor 6 | - Firebase/Messaging 7 | - CapacitorCordova (3.2.4) 8 | - CapacitorPushNotifications (1.0.4): 9 | - Capacitor 10 | - Firebase/CoreOnly (8.8.0): 11 | - FirebaseCore (= 8.8.0) 12 | - Firebase/Messaging (8.8.0): 13 | - Firebase/CoreOnly 14 | - FirebaseMessaging (~> 8.8.0) 15 | - FirebaseCore (8.8.0): 16 | - FirebaseCoreDiagnostics (~> 8.0) 17 | - GoogleUtilities/Environment (~> 7.4) 18 | - GoogleUtilities/Logger (~> 7.4) 19 | - FirebaseCoreDiagnostics (8.8.0): 20 | - GoogleDataTransport (~> 9.0) 21 | - GoogleUtilities/Environment (~> 7.4) 22 | - GoogleUtilities/Logger (~> 7.4) 23 | - nanopb (~> 2.30908.0) 24 | - FirebaseInstallations (8.8.0): 25 | - FirebaseCore (~> 8.0) 26 | - GoogleUtilities/Environment (~> 7.4) 27 | - GoogleUtilities/UserDefaults (~> 7.4) 28 | - PromisesObjC (< 3.0, >= 1.2) 29 | - FirebaseMessaging (8.8.0): 30 | - FirebaseCore (~> 8.0) 31 | - FirebaseInstallations (~> 8.0) 32 | - GoogleDataTransport (~> 9.0) 33 | - GoogleUtilities/AppDelegateSwizzler (~> 7.4) 34 | - GoogleUtilities/Environment (~> 7.4) 35 | - GoogleUtilities/Reachability (~> 7.4) 36 | - GoogleUtilities/UserDefaults (~> 7.4) 37 | - nanopb (~> 2.30908.0) 38 | - GoogleDataTransport (9.1.0): 39 | - GoogleUtilities/Environment (~> 7.2) 40 | - nanopb (~> 2.30908.0) 41 | - PromisesObjC (< 3.0, >= 1.2) 42 | - GoogleUtilities/AppDelegateSwizzler (7.5.2): 43 | - GoogleUtilities/Environment 44 | - GoogleUtilities/Logger 45 | - GoogleUtilities/Network 46 | - GoogleUtilities/Environment (7.5.2): 47 | - PromisesObjC (< 3.0, >= 1.2) 48 | - GoogleUtilities/Logger (7.5.2): 49 | - GoogleUtilities/Environment 50 | - GoogleUtilities/Network (7.5.2): 51 | - GoogleUtilities/Logger 52 | - "GoogleUtilities/NSData+zlib" 53 | - GoogleUtilities/Reachability 54 | - "GoogleUtilities/NSData+zlib (7.5.2)" 55 | - GoogleUtilities/Reachability (7.5.2): 56 | - GoogleUtilities/Logger 57 | - GoogleUtilities/UserDefaults (7.5.2): 58 | - GoogleUtilities/Logger 59 | - nanopb (2.30908.0): 60 | - nanopb/decode (= 2.30908.0) 61 | - nanopb/encode (= 2.30908.0) 62 | - nanopb/decode (2.30908.0) 63 | - nanopb/encode (2.30908.0) 64 | - PromisesObjC (2.0.0) 65 | 66 | DEPENDENCIES: 67 | - "Capacitor (from `../../node_modules/@capacitor/ios`)" 68 | - CapacitorCommunityFcm (from `../../..`) 69 | - "CapacitorCordova (from `../../node_modules/@capacitor/ios`)" 70 | - "CapacitorPushNotifications (from `../../node_modules/@capacitor/push-notifications`)" 71 | 72 | SPEC REPOS: 73 | trunk: 74 | - Firebase 75 | - FirebaseCore 76 | - FirebaseCoreDiagnostics 77 | - FirebaseInstallations 78 | - FirebaseMessaging 79 | - GoogleDataTransport 80 | - GoogleUtilities 81 | - nanopb 82 | - PromisesObjC 83 | 84 | EXTERNAL SOURCES: 85 | Capacitor: 86 | :path: "../../node_modules/@capacitor/ios" 87 | CapacitorCommunityFcm: 88 | :path: "../../.." 89 | CapacitorCordova: 90 | :path: "../../node_modules/@capacitor/ios" 91 | CapacitorPushNotifications: 92 | :path: "../../node_modules/@capacitor/push-notifications" 93 | 94 | SPEC CHECKSUMS: 95 | Capacitor: 07f746722420584674243fe6bb2e02d243a02a08 96 | CapacitorCommunityFcm: af38ba6452104d1b3c4eef9007d9856b2805a6e8 97 | CapacitorCordova: 16f118e79d7c20eb659565b1ed9133e2b730f747 98 | CapacitorPushNotifications: d06d6267cd165b430ef75d1f3a6d0bb2872099ec 99 | Firebase: 629510f1a9ddb235f3a7c5c8ceb23ba887f0f814 100 | FirebaseCore: 98b29e3828f0a53651c363937a7f7d92a19f1ba2 101 | FirebaseCoreDiagnostics: fe77f42da6329d6d83d21fd9d621a6b704413bfc 102 | FirebaseInstallations: 2563cb18a723ef9c6ef18318a49519b75dce613c 103 | FirebaseMessaging: 419b5c9d84f294a753c6501d8cfb9ced1ce37304 104 | GoogleDataTransport: 85fd18ff3019bb85d3f2c551d04c481dedf71fc9 105 | GoogleUtilities: 8de2a97a17e15b6b98e38e8770e2d129a57c0040 106 | nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 107 | PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58 108 | 109 | PODFILE CHECKSUM: 3de3331be79bee8671f1dbb1f776758053cfdeae 110 | 111 | COCOAPODS: 1.11.0 112 | -------------------------------------------------------------------------------- /android/src/main/java/com/getcapacitor/community/fcm/FCMPlugin.java: -------------------------------------------------------------------------------- 1 | package com.getcapacitor.community.fcm; 2 | 3 | import android.util.Log; 4 | import com.getcapacitor.JSObject; 5 | import com.getcapacitor.Plugin; 6 | import com.getcapacitor.PluginCall; 7 | import com.getcapacitor.PluginMethod; 8 | import com.getcapacitor.annotation.CapacitorPlugin; 9 | import com.google.firebase.installations.FirebaseInstallations; 10 | import com.google.firebase.messaging.FirebaseMessaging; 11 | 12 | /** 13 | * Please read the Capacitor Android Plugin Development Guide 14 | * here: https://capacitor.ionicframework.com/docs/plugins/android 15 | * 16 | * Created by Stewan Silva on 1/23/19. 17 | */ 18 | @CapacitorPlugin(name = "FCM") 19 | public class FCMPlugin extends Plugin { 20 | 21 | public static final String TAG = "FirebaseMessaging"; 22 | 23 | @PluginMethod 24 | public void subscribeTo(final PluginCall call) { 25 | final String topicName = call.getString("topic"); 26 | 27 | FirebaseMessaging.getInstance() 28 | .subscribeToTopic(topicName) 29 | .addOnSuccessListener(aVoid -> { 30 | JSObject ret = new JSObject(); 31 | ret.put("message", "Subscribed to topic " + topicName); 32 | call.resolve(ret); 33 | }) 34 | .addOnFailureListener(e -> call.reject("Cant subscribe to topic" + topicName, e)); 35 | } 36 | 37 | @PluginMethod 38 | public void unsubscribeFrom(final PluginCall call) { 39 | final String topicName = call.getString("topic"); 40 | 41 | FirebaseMessaging.getInstance() 42 | .unsubscribeFromTopic(topicName) 43 | .addOnSuccessListener(aVoid -> { 44 | JSObject ret = new JSObject(); 45 | ret.put("message", "Unsubscribed from topic " + topicName); 46 | call.resolve(ret); 47 | }) 48 | .addOnFailureListener(e -> call.reject("Cant unsubscribe from topic" + topicName, e)); 49 | } 50 | 51 | @PluginMethod 52 | public void deleteInstance(final PluginCall call) { 53 | FirebaseInstallations.getInstance() 54 | .delete() 55 | .addOnSuccessListener(aVoid -> call.resolve()) 56 | .addOnFailureListener(e -> { 57 | e.printStackTrace(); 58 | call.reject("Cant delete Firebase Instance ID", e); 59 | }); 60 | } 61 | 62 | @PluginMethod 63 | public void getToken(final PluginCall call) { 64 | FirebaseMessaging.getInstance() 65 | .getToken() 66 | .addOnCompleteListener(getActivity(), tokenResult -> { 67 | if (!tokenResult.isSuccessful()) { 68 | Exception exception = tokenResult.getException(); 69 | Log.w(TAG, "Fetching FCM registration token failed", exception); 70 | call.errorCallback(exception.getLocalizedMessage()); 71 | return; 72 | } 73 | JSObject data = new JSObject(); 74 | data.put("token", tokenResult.getResult()); 75 | call.resolve(data); 76 | }); 77 | 78 | FirebaseMessaging.getInstance().getToken().addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e)); 79 | } 80 | 81 | @PluginMethod 82 | public void refreshToken(final PluginCall call) { 83 | FirebaseMessaging.getInstance() 84 | .deleteToken() 85 | .addOnCompleteListener(result -> { 86 | FirebaseMessaging.getInstance() 87 | .getToken() 88 | .addOnCompleteListener(getActivity(), tokenResult -> { 89 | JSObject data = new JSObject(); 90 | data.put("token", tokenResult.getResult()); 91 | call.resolve(data); 92 | }) 93 | .addOnFailureListener(e -> call.reject("Failed to get FCM registration token", e)); 94 | }) 95 | .addOnFailureListener(e -> call.reject("Failed to delete FCM registration token", e)); 96 | } 97 | 98 | @PluginMethod 99 | public void setAutoInit(final PluginCall call) { 100 | final boolean enabled = call.getBoolean("enabled", false); 101 | FirebaseMessaging.getInstance().setAutoInitEnabled(enabled); 102 | call.resolve(); 103 | } 104 | 105 | @PluginMethod 106 | public void isAutoInitEnabled(final PluginCall call) { 107 | final boolean enabled = FirebaseMessaging.getInstance().isAutoInitEnabled(); 108 | JSObject data = new JSObject(); 109 | data.put("enabled", enabled); 110 | call.resolve(data); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /ios/Plugin/Plugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Capacitor 3 | import UserNotifications 4 | 5 | import FirebaseCore 6 | import FirebaseMessaging 7 | import FirebaseInstallations 8 | 9 | /** 10 | * Please read the Capacitor iOS Plugin Development Guide 11 | * here: https://capacitor.ionicframework.com/docs/plugins/ios 12 | * 13 | * Created by Stewan Silva on 1/23/19. 14 | */ 15 | @objc(FCMPlugin) 16 | public class FCMPlugin: CAPPlugin, MessagingDelegate { 17 | var fcmToken: String? 18 | 19 | override public func load() { 20 | if FirebaseApp.app() == nil { 21 | FirebaseApp.configure() 22 | } 23 | Messaging.messaging().delegate = self 24 | NotificationCenter.default.addObserver(self, selector: #selector(self.didRegisterWithToken(notification:)), name: .capacitorDidRegisterForRemoteNotifications, object: nil) 25 | } 26 | 27 | @objc func didRegisterWithToken(notification: NSNotification) { 28 | guard let deviceToken = notification.object as? Data else { 29 | return 30 | } 31 | Messaging.messaging().apnsToken = deviceToken 32 | } 33 | 34 | @objc func subscribeTo(_ call: CAPPluginCall) { 35 | let topicName = call.getString("topic") ?? "" 36 | Messaging.messaging().subscribe(toTopic: topicName) { error in 37 | // print("Subscribed to weather topic") 38 | if (error) != nil { 39 | print("ERROR while trying to subscribe topic \(topicName)") 40 | call.reject("Can't subscribe to topic \(topicName)") 41 | } else { 42 | call.resolve([ 43 | "message": "subscribed to topic \(topicName)" 44 | ]) 45 | } 46 | } 47 | } 48 | 49 | @objc func unsubscribeFrom(_ call: CAPPluginCall) { 50 | let topicName = call.getString("topic") ?? "" 51 | Messaging.messaging().unsubscribe(fromTopic: topicName) { error in 52 | if (error) != nil { 53 | call.reject("Can't unsubscribe from topic \(topicName)") 54 | } else { 55 | call.resolve([ 56 | "message": "unsubscribed from topic \(topicName)" 57 | ]) 58 | } 59 | } 60 | } 61 | 62 | @objc func getToken(_ call: CAPPluginCall) { 63 | if (fcmToken ?? "").isEmpty { 64 | Messaging.messaging().token { token, error in 65 | if let error = error { 66 | print("Error fetching FCM registration token: \(error)") 67 | call.reject("Failed to get instance FirebaseID", error.localizedDescription) 68 | } else if let token = token { 69 | print("FCM registration token: \(token)") 70 | self.fcmToken = token 71 | call.resolve([ 72 | "token": token 73 | ]) 74 | } 75 | } 76 | } else { 77 | call.resolve([ 78 | "token": fcmToken 79 | ]) 80 | } 81 | } 82 | 83 | @objc func refreshToken(_ call: CAPPluginCall) { 84 | // Delete FCM Token on Firebase 85 | FirebaseMessaging.Messaging.messaging().deleteData { error in 86 | guard let error = error else { 87 | print("Delete FCMToken successful!") 88 | return 89 | } 90 | call.reject("Delete FCMToken failed", error.localizedDescription) 91 | print("Delete FCMToken failed: \(String(describing: error.localizedDescription))!") 92 | } 93 | 94 | Messaging.messaging().token { token, error in 95 | if let error = error { 96 | print("Error fetching FCM registration token: \(error)") 97 | call.reject("Failed to get instance FirebaseID", error.localizedDescription) 98 | } else if let token = token { 99 | print("FCM registration token: \(token)") 100 | self.fcmToken = token 101 | call.resolve([ 102 | "token": token 103 | ]) 104 | } 105 | } 106 | } 107 | 108 | @objc func deleteInstance(_ call: CAPPluginCall) { 109 | Installations.installations().delete { error in 110 | if let error = error { 111 | print("Error deleting installation: \(error)") 112 | call.reject("Cant delete Firebase Instance ID", error.localizedDescription) 113 | } 114 | // reset fcmToken 115 | self.fcmToken = "" 116 | call.resolve() 117 | } 118 | } 119 | 120 | @objc func setAutoInit(_ call: CAPPluginCall) { 121 | let enabled: Bool = call.getBool("enabled") ?? false 122 | Messaging.messaging().isAutoInitEnabled = enabled 123 | call.resolve() 124 | } 125 | 126 | @objc func isAutoInitEnabled(_ call: CAPPluginCall) { 127 | call.resolve([ 128 | "enabled": Messaging.messaging().isAutoInitEnabled 129 | ]) 130 | } 131 | 132 | @objc public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { 133 | self.fcmToken = fcmToken 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /example/ios/App/App/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Capacitor 3 | 4 | @UIApplicationMain 5 | class AppDelegate: UIResponder, UIApplicationDelegate { 6 | 7 | var window: UIWindow? 8 | 9 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 10 | 11 | return true 12 | } 13 | 14 | func applicationWillResignActive(_ application: UIApplication) { 15 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 16 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 17 | } 18 | 19 | func applicationDidEnterBackground(_ application: UIApplication) { 20 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 21 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 22 | } 23 | 24 | func applicationWillEnterForeground(_ application: UIApplication) { 25 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 26 | } 27 | 28 | func applicationDidBecomeActive(_ application: UIApplication) { 29 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 30 | // let settings = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil) 31 | // application.registerUserNotificationSettings(settings) 32 | // application.registerForRemoteNotifications() 33 | 34 | // application.registerForRemoteNotifications() 35 | } 36 | 37 | func applicationWillTerminate(_ application: UIApplication) { 38 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 39 | } 40 | 41 | func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { 42 | // Called when the app was launched with a url. Feel free to add additional processing here, 43 | // but if you want the App API to support tracking app url opens, make sure to keep this call 44 | return ApplicationDelegateProxy.shared.application(app, open: url, options: options) 45 | } 46 | 47 | func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { 48 | // Called when the app was launched with an activity, including Universal Links. 49 | // Feel free to add additional processing here, but if you want the App API to support 50 | // tracking app url opens, make sure to keep this call 51 | return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler) 52 | } 53 | 54 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 55 | super.touchesBegan(touches, with: event) 56 | 57 | let statusBarRect = UIApplication.shared.statusBarFrame 58 | guard let touchPoint = event?.allTouches?.first?.location(in: self.window) else { return } 59 | 60 | if statusBarRect.contains(touchPoint) { 61 | NotificationCenter.default.post(name: .capacitorStatusBarTapped, object: nil) 62 | } 63 | } 64 | 65 | #if USE_PUSH 66 | 67 | func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { 68 | NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken) 69 | } 70 | 71 | func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { 72 | NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error) 73 | } 74 | 75 | #endif 76 | 77 | func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { 78 | // If you are receiving a notification message while your app is in the background, 79 | // this callback will not be fired till the user taps on the notification launching the application. 80 | // TODO: Handle data of notification 81 | 82 | // With swizzling disabled you must let Messaging know about the message, for Analytics 83 | // Messaging.messaging().appDidReceiveMessage(userInfo) 84 | 85 | // Print message ID. 86 | // if let messageID = userInfo[gcmMessageIDKey] { 87 | // print("Message ID: \(messageID)") 88 | // } 89 | 90 | // Print full message. 91 | print(userInfo) 92 | } 93 | 94 | func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], 95 | fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { 96 | // If you are receiving a notification message while your app is in the background, 97 | // this callback will not be fired till the user taps on the notification launching the application. 98 | // TODO: Handle data of notification 99 | 100 | // With swizzling disabled you must let Messaging know about the message, for Analytics 101 | // Messaging.messaging().appDidReceiveMessage(userInfo) 102 | 103 | // Print message ID. 104 | // if let messageID = userInfo[gcmMessageIDKey] { 105 | // print("Message ID: \(messageID)") 106 | // } 107 | 108 | // Print full message. 109 | print(userInfo) 110 | 111 | completionHandler(UIBackgroundFetchResult.newData) 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /example/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", 3 | "version": 1, 4 | "defaultProject": "app", 5 | "newProjectRoot": "projects", 6 | "projects": { 7 | "app": { 8 | "root": "", 9 | "sourceRoot": "src", 10 | "projectType": "application", 11 | "prefix": "app", 12 | "schematics": {}, 13 | "architect": { 14 | "build": { 15 | "builder": "@angular-devkit/build-angular:browser", 16 | "options": { 17 | "outputPath": "www", 18 | "index": "src/index.html", 19 | "main": "src/main.ts", 20 | "polyfills": "src/polyfills.ts", 21 | "tsConfig": "src/tsconfig.app.json", 22 | "assets": [ 23 | { 24 | "glob": "**/*", 25 | "input": "src/assets", 26 | "output": "assets" 27 | }, 28 | { 29 | "glob": "**/*.svg", 30 | "input": "node_modules/ionicons/dist/ionicons/svg", 31 | "output": "./svg" 32 | } 33 | ], 34 | "styles": [ 35 | { 36 | "input": "src/theme/variables.scss" 37 | }, 38 | { 39 | "input": "src/global.scss" 40 | }, 41 | { 42 | "input": "src/app/app.scss" 43 | } 44 | ], 45 | "scripts": [], 46 | "es5BrowserSupport": true 47 | }, 48 | "configurations": { 49 | "production": { 50 | "fileReplacements": [ 51 | { 52 | "replace": "src/environments/environment.ts", 53 | "with": "src/environments/environment.prod.ts" 54 | } 55 | ], 56 | "optimization": true, 57 | "outputHashing": "all", 58 | "sourceMap": false, 59 | "extractCss": true, 60 | "namedChunks": false, 61 | "aot": true, 62 | "extractLicenses": true, 63 | "vendorChunk": false, 64 | "buildOptimizer": true, 65 | "budgets": [ 66 | { 67 | "type": "initial", 68 | "maximumWarning": "2mb", 69 | "maximumError": "5mb" 70 | } 71 | ] 72 | }, 73 | "ci": { 74 | "progress": false 75 | } 76 | } 77 | }, 78 | "serve": { 79 | "builder": "@angular-devkit/build-angular:dev-server", 80 | "options": { 81 | "browserTarget": "app:build" 82 | }, 83 | "configurations": { 84 | "production": { 85 | "browserTarget": "app:build:production" 86 | }, 87 | "ci": { 88 | "progress": false 89 | } 90 | } 91 | }, 92 | "extract-i18n": { 93 | "builder": "@angular-devkit/build-angular:extract-i18n", 94 | "options": { 95 | "browserTarget": "app:build" 96 | } 97 | }, 98 | "test": { 99 | "builder": "@angular-devkit/build-angular:karma", 100 | "options": { 101 | "main": "src/test.ts", 102 | "polyfills": "src/polyfills.ts", 103 | "tsConfig": "src/tsconfig.spec.json", 104 | "karmaConfig": "src/karma.conf.js", 105 | "styles": [], 106 | "scripts": [], 107 | "assets": [ 108 | { 109 | "glob": "favicon.ico", 110 | "input": "src/", 111 | "output": "/" 112 | }, 113 | { 114 | "glob": "**/*", 115 | "input": "src/assets", 116 | "output": "/assets" 117 | } 118 | ] 119 | }, 120 | "configurations": { 121 | "ci": { 122 | "progress": false, 123 | "watch": false 124 | } 125 | } 126 | }, 127 | "lint": { 128 | "builder": "@angular-devkit/build-angular:tslint", 129 | "options": { 130 | "tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"], 131 | "exclude": ["**/node_modules/**"] 132 | } 133 | }, 134 | "ionic-cordova-build": { 135 | "builder": "@ionic/angular-toolkit:cordova-build", 136 | "options": { 137 | "browserTarget": "app:build" 138 | }, 139 | "configurations": { 140 | "production": { 141 | "browserTarget": "app:build:production" 142 | } 143 | } 144 | }, 145 | "ionic-cordova-serve": { 146 | "builder": "@ionic/angular-toolkit:cordova-serve", 147 | "options": { 148 | "cordovaBuildTarget": "app:ionic-cordova-build", 149 | "devServerTarget": "app:serve" 150 | }, 151 | "configurations": { 152 | "production": { 153 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 154 | "devServerTarget": "app:serve:production" 155 | } 156 | } 157 | } 158 | } 159 | }, 160 | "app-e2e": { 161 | "root": "e2e/", 162 | "projectType": "application", 163 | "architect": { 164 | "e2e": { 165 | "builder": "@angular-devkit/build-angular:protractor", 166 | "options": { 167 | "protractorConfig": "e2e/protractor.conf.js", 168 | "devServerTarget": "app:serve" 169 | }, 170 | "configurations": { 171 | "production": { 172 | "devServerTarget": "app:serve:production" 173 | }, 174 | "ci": { 175 | "devServerTarget": "app:serve:ci" 176 | } 177 | } 178 | }, 179 | "lint": { 180 | "builder": "@angular-devkit/build-angular:tslint", 181 | "options": { 182 | "tsConfig": "e2e/tsconfig.e2e.json", 183 | "exclude": ["**/node_modules/**"] 184 | } 185 | } 186 | } 187 | } 188 | }, 189 | "cli": { 190 | "defaultCollection": "@ionic/angular-toolkit" 191 | }, 192 | "schematics": { 193 | "@ionic/angular-toolkit:component": { 194 | "styleext": "scss" 195 | }, 196 | "@ionic/angular-toolkit:page": { 197 | "styleext": "scss" 198 | } 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "fcm", 3 | "projectOwner": "capacitor-community", 4 | "repoType": "github", 5 | "repoHost": "https://github.com", 6 | "files": [ 7 | "README.md" 8 | ], 9 | "imageSize": 75, 10 | "commit": true, 11 | "commitConvention": "angular", 12 | "badgeTemplate": "-orange?style=flat-square\" />", 13 | "contributors": [ 14 | { 15 | "login": "stewones", 16 | "name": "stewones", 17 | "avatar_url": "https://avatars1.githubusercontent.com/u/719763?v=4", 18 | "profile": "https://twitter.com/stewones", 19 | "contributions": [ 20 | "code", 21 | "doc" 22 | ] 23 | }, 24 | { 25 | "login": "danielprrazevedo", 26 | "name": "Daniel Pereira", 27 | "avatar_url": "https://avatars2.githubusercontent.com/u/20153661?v=4", 28 | "profile": "https://github.com/danielprrazevedo", 29 | "contributions": [ 30 | "code", 31 | "doc" 32 | ] 33 | }, 34 | { 35 | "login": "priyankpat", 36 | "name": "Priyank Patel", 37 | "avatar_url": "https://avatars3.githubusercontent.com/u/5585797?v=4", 38 | "profile": "http://priyankpatel.io/", 39 | "contributions": [ 40 | "code" 41 | ] 42 | }, 43 | { 44 | "login": "nikoskip", 45 | "name": "Nikolas", 46 | "avatar_url": "https://avatars1.githubusercontent.com/u/1230033?v=4", 47 | "profile": "http://fuubar.wordpress.com/", 48 | "contributions": [ 49 | "maintenance" 50 | ] 51 | }, 52 | { 53 | "login": "lights0123", 54 | "name": "Ben Schattinger", 55 | "avatar_url": "https://avatars3.githubusercontent.com/u/3756309?v=4", 56 | "profile": "https://lights0123.com/", 57 | "contributions": [ 58 | "code" 59 | ] 60 | }, 61 | { 62 | "login": "jmannau", 63 | "name": "James Manners", 64 | "avatar_url": "https://avatars2.githubusercontent.com/u/175909?v=4", 65 | "profile": "https://binary.com.au/", 66 | "contributions": [ 67 | "code" 68 | ] 69 | }, 70 | { 71 | "login": "borodiliz", 72 | "name": "Borja Rodríguez", 73 | "avatar_url": "https://avatars3.githubusercontent.com/u/2467193?v=4", 74 | "profile": "https://github.com/borodiliz", 75 | "contributions": [ 76 | "maintenance" 77 | ] 78 | }, 79 | { 80 | "login": "Karrlllis", 81 | "name": "Karrlllis", 82 | "avatar_url": "https://avatars1.githubusercontent.com/u/37330643?v=4", 83 | "profile": "https://github.com/Karrlllis", 84 | "contributions": [ 85 | "doc" 86 | ] 87 | }, 88 | { 89 | "login": "jamesmah", 90 | "name": "jamesmah", 91 | "avatar_url": "https://avatars0.githubusercontent.com/u/21981049?v=4", 92 | "profile": "https://github.com/jamesmah", 93 | "contributions": [ 94 | "code" 95 | ] 96 | }, 97 | { 98 | "login": "josh-m-sharpe", 99 | "name": "Josh Sharpe", 100 | "avatar_url": "https://avatars3.githubusercontent.com/u/39473?v=4", 101 | "profile": "https://github.com/josh-m-sharpe", 102 | "contributions": [ 103 | "maintenance" 104 | ] 105 | }, 106 | { 107 | "login": "msimkunas", 108 | "name": "Mantas Šimkūnas", 109 | "avatar_url": "https://avatars.githubusercontent.com/u/9675250?v=4", 110 | "profile": "https://github.com/msimkunas", 111 | "contributions": [ 112 | "code", 113 | "doc" 114 | ] 115 | }, 116 | { 117 | "login": "iOlivier", 118 | "name": "Olivier Overstraete", 119 | "avatar_url": "https://avatars.githubusercontent.com/u/12254953?v=4", 120 | "profile": "https://github.com/iOlivier", 121 | "contributions": [ 122 | "maintenance" 123 | ] 124 | }, 125 | { 126 | "login": "hemangsk", 127 | "name": "Hemang Kumar", 128 | "avatar_url": "https://avatars.githubusercontent.com/u/13018570?v=4", 129 | "profile": "https://hemang.dev/", 130 | "contributions": [ 131 | "code", 132 | "maintenance" 133 | ] 134 | }, 135 | { 136 | "login": "mesqueeb", 137 | "name": "Luca Ban", 138 | "avatar_url": "https://avatars.githubusercontent.com/u/3253920?v=4", 139 | "profile": "https://github.com/mesqueeb", 140 | "contributions": [ 141 | "doc" 142 | ] 143 | }, 144 | { 145 | "login": "halomademeapc", 146 | "name": "Alex Griffith", 147 | "avatar_url": "https://avatars.githubusercontent.com/u/5904472?v=4", 148 | "profile": "https://www.alexgriffith.me/", 149 | "contributions": [ 150 | "code", 151 | "maintenance" 152 | ] 153 | }, 154 | { 155 | "login": "bdirito", 156 | "name": "bdirito", 157 | "avatar_url": "https://avatars.githubusercontent.com/u/8117238?v=4", 158 | "profile": "https://github.com/bdirito", 159 | "contributions": [ 160 | "maintenance" 161 | ] 162 | }, 163 | { 164 | "login": "mineminemine", 165 | "name": "Ryan", 166 | "avatar_url": "https://avatars.githubusercontent.com/u/17585549?v=4", 167 | "profile": "https://github.com/mineminemine", 168 | "contributions": [ 169 | "maintenance" 170 | ] 171 | }, 172 | { 173 | "login": "josuelmm", 174 | "name": "Josué Moreno", 175 | "avatar_url": "https://avatars.githubusercontent.com/u/12968781?v=4", 176 | "profile": "https://github.com/josuelmm", 177 | "contributions": [ 178 | "code" 179 | ] 180 | }, 181 | { 182 | "login": "marcjulian", 183 | "name": "Marc", 184 | "avatar_url": "https://avatars.githubusercontent.com/u/8985933?v=4", 185 | "profile": "https://marcjulian.de/?ref=github", 186 | "contributions": [ 187 | "maintenance" 188 | ] 189 | }, 190 | { 191 | "login": "flogy", 192 | "name": "Florian Gyger", 193 | "avatar_url": "https://avatars.githubusercontent.com/u/1215256?v=4", 194 | "profile": "https://floriangyger.ch/", 195 | "contributions": [ 196 | "code" 197 | ] 198 | }, 199 | { 200 | "login": "jcesarmobile", 201 | "name": "jcesarmobile", 202 | "avatar_url": "https://avatars.githubusercontent.com/u/1637892?v=4", 203 | "profile": "http://www.jcesarmobile.com/", 204 | "contributions": [ 205 | "question", 206 | "doc", 207 | "maintenance" 208 | ] 209 | }, 210 | { 211 | "login": "ramikhafagi96", 212 | "name": "Rami Khafagi", 213 | "avatar_url": "https://avatars.githubusercontent.com/u/38646828?v=4", 214 | "profile": "https://github.com/ramikhafagi96", 215 | "contributions": [ 216 | "code" 217 | ] 218 | }, 219 | { 220 | "login": "bipoza", 221 | "name": "Bittor Poza", 222 | "avatar_url": "https://avatars.githubusercontent.com/u/26112509?v=4", 223 | "profile": "https://github.com/bipoza", 224 | "contributions": [ 225 | "code" 226 | ] 227 | }, 228 | { 229 | "login": "Vishal-Isharani", 230 | "name": "Vishal Isharani", 231 | "avatar_url": "https://avatars.githubusercontent.com/u/10386581?v=4", 232 | "profile": "https://github.com/Vishal-Isharani", 233 | "contributions": [ 234 | "maintenance", 235 | "code" 236 | ] 237 | }, 238 | { 239 | "login": "kashz", 240 | "name": "Shunta KARASAWA", 241 | "avatar_url": "https://avatars.githubusercontent.com/u/12661101?v=4", 242 | "profile": "https://github.com/kashz", 243 | "contributions": [ 244 | "maintenance" 245 | ] 246 | }, 247 | { 248 | "login": "chrisweight", 249 | "name": "Chris Weight", 250 | "avatar_url": "https://avatars.githubusercontent.com/u/468638?v=4", 251 | "profile": "http://www.chrisweight.com/", 252 | "contributions": [ 253 | "maintenance" 254 | ] 255 | }, 256 | { 257 | "login": "ViMaSter", 258 | "name": "Vincent Mahnke", 259 | "avatar_url": "https://avatars.githubusercontent.com/u/1689033?v=4", 260 | "profile": "https://by.vincent.mahn.ke/", 261 | "contributions": [ 262 | "maintenance" 263 | ] 264 | }, 265 | { 266 | "login": "tompidom", 267 | "name": "tompidom", 268 | "avatar_url": "https://avatars.githubusercontent.com/u/47992794?v=4", 269 | "profile": "https://github.com/tompidom", 270 | "contributions": [ 271 | "infra" 272 | ] 273 | } 274 | ], 275 | "contributorsPerLine": 5 276 | } 277 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [8.0.1](https://github.com/capacitor-community/fcm/compare/v8.0.0...v8.0.1) (2025-12-04) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * keep ios 14 support for now and pin firebase to 11 ([33315ee](https://github.com/capacitor-community/fcm/commit/33315ee3acbd75418085dbc9521b86f763c610ab)) 11 | 12 | ## [8.0.0](https://github.com/capacitor-community/fcm/compare/v7.3.0...v8.0.0) (2025-12-04) 13 | 14 | ### Features 15 | 16 | * iOS Swift Package definition ([#182](https://github.com/capacitor-community/fcm/issues/182)) ([bdfc5d7](https://github.com/capacitor-community/fcm/commit/bdfc5d7b669156be8483df03144aee7d4c47a45d)) 17 | 18 | 19 | ### [7.1.3](https://github.com/capacitor-community/fcm/compare/v7.1.1...v7.1.3) (2025-08-23) 20 | 21 | 22 | ### Bug Fixes 23 | 24 | * revert mistake closes [#180](https://github.com/capacitor-community/fcm/issues/180) ([5515b06](https://github.com/capacitor-community/fcm/commit/5515b0662fe2ebdded9f318d7ebd3745501a9a55)) 25 | 26 | ### [7.1.1](https://github.com/capacitor-community/fcm/compare/v7.1.0...v7.1.1) (2025-03-18) 27 | 28 | 29 | ### Bug Fixes 30 | 31 | * Remove res folder ([#174](https://github.com/capacitor-community/fcm/issues/174)) ([aeb4fa5](https://github.com/capacitor-community/fcm/commit/aeb4fa574910744e7ed631b6213d1c6ebfa5055a)) 32 | 33 | ## [7.1.0](https://github.com/capacitor-community/fcm/compare/v7.0.0...v7.1.0) (2025-03-06) 34 | 35 | ## [7.0.0](https://github.com/capacitor-community/fcm/compare/v6.0.1...v7.0.0) (2025-02-04) 36 | 37 | 38 | ### Features 39 | 40 | * update to Capacitor 7 ([#166](https://github.com/capacitor-community/fcm/issues/166)) ([df01cbb](https://github.com/capacitor-community/fcm/commit/df01cbbd3fb7c03d2d7c2ae00484f314cedc3d2a)) 41 | 42 | ### [6.0.1](https://github.com/capacitor-community/fcm/compare/v6.0.0...v6.0.1) (2025-02-02) 43 | 44 | 45 | ### Bug Fixes 46 | 47 | * Reset fcmToken var when deleteInstance method called. ([#165](https://github.com/capacitor-community/fcm/issues/165)) ([46e8bf2](https://github.com/capacitor-community/fcm/commit/46e8bf2fd15b583c38fb8659ead7223892dcab4e)) 48 | 49 | ## [6.0.0](https://github.com/capacitor-community/fcm/compare/v5.0.3...v6.0.0) (2024-05-23) 50 | 51 | 52 | ### Features 53 | 54 | * update to Capacitor 6 ([#158](https://github.com/capacitor-community/fcm/issues/158)) ([871eb53](https://github.com/capacitor-community/fcm/commit/871eb530c72ef5be2e732678324003bcba96431a)) 55 | 56 | ### [5.0.3](https://github.com/capacitor-community/fcm/compare/v5.0.2...v5.0.3) (2024-02-20) 57 | 58 | 59 | ### Bug Fixes 60 | 61 | * Add refreshToken method to Plugin.m ([#155](https://github.com/capacitor-community/fcm/issues/155)) ([72da269](https://github.com/capacitor-community/fcm/commit/72da269fd6917f3123eb394233a412ccd8a9edab)) 62 | 63 | ### [5.0.2](https://github.com/capacitor-community/fcm/compare/v5.0.1...v5.0.2) (2023-08-29) 64 | 65 | ### [5.0.1](https://github.com/capacitor-community/fcm/compare/v5.0.0...v5.0.1) (2023-05-08) 66 | 67 | 68 | ### Bug Fixes 69 | 70 | * Use Capacitor ^5.0.0 instead of next ([#145](https://github.com/capacitor-community/fcm/issues/145)) ([d8f6354](https://github.com/capacitor-community/fcm/commit/d8f6354d8d7c5d83df0cfc6d8d391c0638081e8b)) 71 | 72 | ## [5.0.0](https://github.com/capacitor-community/fcm/compare/v4.0.0...v5.0.0) (2023-05-08) 73 | 74 | ## [4.0.0](https://github.com/capacitor-community/fcm/compare/v3.0.2...v4.0.0) (2023-05-08) 75 | 76 | 77 | ### ⚠ BREAKING CHANGES 78 | 79 | * Update to Capacitor 5 (#144) 80 | 81 | ### Features 82 | 83 | * Update to Capacitor 5 ([#144](https://github.com/capacitor-community/fcm/issues/144)) ([b453adb](https://github.com/capacitor-community/fcm/commit/b453adbcf358dccd3cdc2ddb0fa485d5d14ba0c4)) 84 | 85 | ### [3.0.2](https://github.com/capacitor-community/fcm/compare/v3.0.1...v3.0.2) (2022-12-07) 86 | 87 | 88 | ### Bug Fixes 89 | 90 | * check if task is successful before accessing result to avoid crashes ([0304daa](https://github.com/capacitor-community/fcm/commit/0304daa54d25305a166661d9040bd7cb107261da)) 91 | 92 | ### [3.0.1](https://github.com/capacitor-community/fcm/compare/v3.0.0...v3.0.1) (2022-11-08) 93 | 94 | 95 | ### Bug Fixes 96 | 97 | * add sponsor ([e2270f6](https://github.com/capacitor-community/fcm/commit/e2270f607287fa1440c5150de57e93f4d52f42d6)) 98 | * **android:** update firebaseMessagingVersion default value ([445b8ac](https://github.com/capacitor-community/fcm/commit/445b8ac805daf3ac52c3ccf0e4b89ed0e93a012d)) 99 | * readme ([1cbc83c](https://github.com/capacitor-community/fcm/commit/1cbc83c7825395ea7310814fa70ed1fd0ca809bb)) 100 | 101 | ### [2.0.2](https://github.com/capacitor-community/fcm/compare/v2.0.1...v2.0.2) (2021-10-04) 102 | 103 | ### [2.0.1](https://github.com/capacitor-community/fcm/compare/v2.0.0...v2.0.1) (2021-09-13) 104 | 105 | ## [2.0.0](https://github.com/capacitor-community/fcm/compare/v1.1.2...v2.0.0) (2021-06-14) 106 | 107 | 108 | ### Bug Fixes 109 | 110 | * upgrade to firebase 8 and fix plugin for capacitor 3 ([3317a8e](https://github.com/capacitor-community/fcm/commit/3317a8e9824b2dbf7d179410a31d7494669f0c51)) 111 | 112 | ### [1.1.2](https://github.com/capacitor-community/fcm/compare/v1.1.0...v1.1.2) (2021-06-11) 113 | 114 | 115 | ### Bug Fixes 116 | 117 | * maintenance badge ([d91eff2](https://github.com/capacitor-community/fcm/commit/d91eff2c32d66bb4a43927b8026d66490098f656)) 118 | * no need of Firebase/Core ([38f186b](https://github.com/capacitor-community/fcm/commit/38f186b09525ee681360b4437ed38c1cc57cb981)) 119 | * podspec ([a3fa50a](https://github.com/capacitor-community/fcm/commit/a3fa50ae039f6a5680d7dd5094675e6ee5a436eb)) 120 | * tweak demo for capacitor v2 ([397409c](https://github.com/capacitor-community/fcm/commit/397409c85881a81fa953f8d51746528ae045587b)) 121 | 122 | ### [1.1.1](https://github.com/capacitor-community/fcm/compare/v1.1.0...v1.1.1) (2021-05-23) 123 | 124 | 125 | ### Bug Fixes 126 | 127 | * no need of Firebase/Core ([38f186b](https://github.com/capacitor-community/fcm/commit/38f186b09525ee681360b4437ed38c1cc57cb981)) 128 | * tweak demo for capacitor v2 ([397409c](https://github.com/capacitor-community/fcm/commit/397409c85881a81fa953f8d51746528ae045587b)) 129 | 130 | ## [1.1.0](https://github.com/capacitor-community/fcm/compare/v1.0.8...v1.1.0) (2021-02-15) 131 | 132 | ### [1.0.8](https://github.com/capacitor-community/fcm/compare/v1.0.7...v1.0.8) (2020-07-11) 133 | 134 | ### Bug Fixes 135 | 136 | - **ios:** get token using instanceID ([f62d33c](https://github.com/capacitor-community/fcm/commit/f62d33cb77e9ce071e2effa71063a740efd9d406)) 137 | 138 | ### [1.0.7](https://github.com/capacitor-community/fcm/compare/v1.0.6...v1.0.7) (2020-07-02) 139 | 140 | - use 2.0.0 instead of latest in package.json 141 | 142 | ### [1.0.6](https://github.com/capacitor-community/fcm/compare/v1.0.5...v1.0.6) (2020-06-29) 143 | 144 | ### Features 145 | 146 | - add example ([1304c79](https://github.com/capacitor-community/fcm/commit/1304c79cf60c772589f2421ff292eac77480887b)) 147 | 148 | ### Bug Fixes 149 | 150 | - **android:** java path ([70a0c9a](https://github.com/capacitor-community/fcm/commit/70a0c9a952f19210e6c237fe9489ddeb3562acc2)) 151 | 152 | ### [1.0.5](https://github.com/capacitor-community/fcm/compare/v1.0.4...v1.0.5) (2020-06-29) 153 | 154 | ### Bug Fixes 155 | 156 | - **android:** refactoring to match community standards. closes [#43](https://github.com/capacitor-community/fcm/issues/43) [#44](https://github.com/capacitor-community/fcm/issues/44) ([11761b8](https://github.com/capacitor-community/fcm/commit/11761b8f024422f89288f940c8a6a146b3ff9a5e)) 157 | 158 | ### [1.0.4](https://github.com/capacitor-community/fcm/compare/v1.0.3...v1.0.4) (2020-06-27) 159 | 160 | ### Bug Fixes 161 | 162 | - contributor links ([73aa017](https://github.com/capacitor-community/fcm/commit/73aa01789a2356711542503c2b864653855c8a50)) 163 | 164 | ### [1.0.3](https://github.com/capacitor-community/fcm/compare/v1.0.2...v1.0.3) (2020-06-27) 165 | 166 | ### [1.0.2](https://github.com/capacitor-community/fcm/compare/v1.0.1...v1.0.2) (2020-06-27) 167 | 168 | ### Bug Fixes 169 | 170 | - podspec name ([1ccad9b](https://github.com/capacitor-community/fcm/commit/1ccad9b45a9462b5315f0e32612696a32dcbecd2)) 171 | 172 | ### [1.0.1](https://github.com/capacitor-community/fcm/compare/v1.0.0...v1.0.1) (2020-06-27) 173 | 174 | ### Bug Fixes 175 | 176 | - **ios:** Fixing wrong Firebase dependency ([6e96be0](https://github.com/capacitor-community/fcm/commit/6e96be0388e67c28c389debd26a11ed3b145e4af)) 177 | 178 | ## 1.0.0 (2020-06-27) 179 | 180 | ### Features 181 | 182 | - **README:** add androidy notes ([9042cba](https://github.com/capacitor-community/fcm/commit/9042cba2bf1182bb0542177ba8fd1303b492009b)) 183 | - add android support ([f3caba1](https://github.com/capacitor-community/fcm/commit/f3caba115a593a9fbb918ee63c2427c3ce5d0870)) 184 | - **FCM:** add subscribe to topic ([6f0f88d](https://github.com/capacitor-community/fcm/commit/6f0f88db173a726ae4b412bfe9b0333f296ed327)) 185 | - **ios:** add getToken and clean project to be publish ([ddec39b](https://github.com/capacitor-community/fcm/commit/ddec39b666e3338a5dd73b39c33510c2eb84c4e7)) 186 | - add README ([863cb25](https://github.com/capacitor-community/fcm/commit/863cb25361fb7ecd8dcd63c64f7181f9d7f5b72f)) 187 | - add unsubscribe from topic ([a6a3dee](https://github.com/capacitor-community/fcm/commit/a6a3dee09b5b2faaca01e50fc2cedb1992df41d5)) 188 | 189 | ### Bug Fixes 190 | 191 | - **android:** add app compat ([5709b1d](https://github.com/capacitor-community/fcm/commit/5709b1dadbd62d1f62b0be86bb1229e9f4e9bc5f)) 192 | - **android:** add deps ([9927aee](https://github.com/capacitor-community/fcm/commit/9927aeee0637945520bea03b69f609a0806b5767)) 193 | - **android:** cap implementation ([b394973](https://github.com/capacitor-community/fcm/commit/b3949730c7ff27afb3a5f4a94dce60360590acde)) 194 | - **android:** package name ([f148a20](https://github.com/capacitor-community/fcm/commit/f148a203551e457a89eed8fedaf24c8fe925b88a)) 195 | - **ios:** notifications were not being delivered on a freshed app install ([f3d10a5](https://github.com/capacitor-community/fcm/commit/f3d10a59a866c0c92cbfd91a3a400c6126de03cb)) 196 | - **ios:** notifications were not being delivered on a freshed app install ([3205224](https://github.com/capacitor-community/fcm/commit/3205224885465a186a830c9679f4b3ce5abdb321)) 197 | - **ios:** plugin not working on Case-Sensitive file system ([1deb869](https://github.com/capacitor-community/fcm/commit/1deb86951dc23a337a7910f5df1bba7e48005d72)) 198 | - **podspec:** add firebase back ([933ddbe](https://github.com/capacitor-community/fcm/commit/933ddbed2b168e2552aae7138914e7ed54d59492)) 199 | - **README:** add sample app link ([ef67512](https://github.com/capacitor-community/fcm/commit/ef67512f94ffb317464006b1eb71a619a9e45079)) 200 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |


2 |

Capacitor FCM

3 |

@capacitor-community/fcm

4 |

5 | Capacitor community plugin for enabling FCM capabilities 6 |

7 | 8 |

9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |

19 | 20 | ## Maintainers 21 | 22 | | Maintainer | GitHub | Social | 23 | | ------------ | --------------------------------------- | ----------------------------------------- | 24 | | Stewan Silva | [stewones](https://github.com/stewones) | [@stewones](https://x.com/stewones) | 25 | 26 | ## Notice 🚀 27 | 28 | We're starting fresh under an official org. If you were using the previous npm package `capacitor-fcm`, please update your package.json to `@capacitor-community/fcm`. Check out [changelog](/CHANGELOG.md) for more info. 29 | 30 | ## Installation 31 | 32 | Using npm: 33 | 34 | ```bash 35 | npm install @capacitor-community/fcm 36 | ``` 37 | 38 | Using yarn: 39 | 40 | ```bash 41 | yarn add @capacitor-community/fcm 42 | ``` 43 | 44 | Sync native files: 45 | 46 | ```bash 47 | npx cap sync 48 | ``` 49 | 50 | > ### Notice 51 | > 52 | > This plugin is intended to be used combined with Capacitor API for [Push Notifications](https://capacitor.ionicframework.com/docs/apis/push-notifications). Capacitor only provides APN token whereas this plugin offers the possibility to work with FCM tokens and more. 53 | 54 | ## API 55 | 56 | | method | info | platform | 57 | | ------------------- | --------------------------------------------- | ----------- | 58 | | `subscribeTo` | subscribe to fcm topic | ios/android | 59 | | `unsubscribeFrom` | unsubscribe from fcm topic | ios/android | 60 | | `getToken` | get fcm token to eventually use from a server | ios/android | 61 | | `refreshToken` | refresh fcm token to get a new one | ios/android | 62 | | `deleteInstance` | remove local fcm instance completely | ios/android | 63 | | `setAutoInit` | enable the auto initialization of the library | ios/android | 64 | | `isAutoInitEnabled` | check whether auto initialization is enabled | ios/android | 65 | 66 | ## Usage 67 | 68 | ```ts 69 | import { FCM } from '@capacitor-community/fcm'; 70 | import { PushNotifications } from '@capacitor/push-notifications'; 71 | 72 | // external required step 73 | // register for push 74 | await PushNotifications.requestPermissions(); 75 | await PushNotifications.register(); 76 | 77 | // now you can subscribe to a specific topic 78 | FCM.subscribeTo({ topic: 'test' }) 79 | .then(r => alert(`subscribed to topic`)) 80 | .catch(err => console.log(err)); 81 | 82 | // Unsubscribe from a specific topic 83 | FCM.unsubscribeFrom({ topic: 'test' }) 84 | .then(() => alert(`unsubscribed from topic`)) 85 | .catch(err => console.log(err)); 86 | 87 | // Get FCM token instead of the APN one returned by Capacitor 88 | FCM.getToken() 89 | .then(r => alert(`Token ${r.token}`)) 90 | .catch(err => console.log(err)); 91 | 92 | // Delete the old FCM token and get a new one 93 | FCM.refreshToken() 94 | .then(r => alert(`Token ${r.token}`)) 95 | .catch(err => console.log(err)); 96 | 97 | // Remove FCM instance 98 | FCM.deleteInstance() 99 | .then(() => alert(`Token deleted`)) 100 | .catch(err => console.log(err)); 101 | 102 | // Enable the auto initialization of the library 103 | FCM.setAutoInit({ enabled: true }).then(() => alert(`Auto init enabled`)); 104 | 105 | // Check the auto initialization status 106 | FCM.isAutoInitEnabled().then(r => { 107 | console.log('Auto init is ' + (r.enabled ? 'enabled' : 'disabled')); 108 | }); 109 | ``` 110 | 111 | ## Add Google config files 112 | 113 | Navigate to the project settings page for your app on Firebase. 114 | 115 | ### iOS 116 | 117 | Download the `GoogleService-Info.plist` file. In Xcode right-click on the yellow folder named "App" and select the `Add files to "App"`. 118 | 119 | > Tip: if you drag and drop your file to this location, Xcode may not be able to find it. 120 | 121 | ### Android 122 | 123 | Download the `google-services.json` file and copy it to `android/app/` directory of your capacitor project. 124 | 125 | ### Certificate 126 | 127 | - apple 128 | - create an app identifier (apple site) 129 | - add push notifications 130 | - add signing request (https://developer.apple.com/help/account/certificates/create-a-certificate-signing-request) 131 | - generate an APN key and then note down the ID displayed. also download the p8 file (https://fluffy.es/p8-push-notification/) 132 | - firebase 133 | - add the downloaded p8 file to firebase settings with noted key ID and the account team ID 134 | 135 | ## iOS setup 136 | 137 | - [Install homebrew](https://capacitorjs.com/docs/getting-started/environment-setup#homebrew) _(once)_ 138 | - `brew install cocoapods` _(once a time)_ 139 | - `ionic start my-cap-app --capacitor` 140 | - `cd my-cap-app` 141 | - `mkdir www && touch www/index.html` 142 | - `npx cap add ios` 143 | - `npm install --save @capacitor-community/fcm` 144 | - `npx cap sync ios` _(always do sync after a plugin install)_ 145 | - `npx cap open ios` 146 | 147 | * sign your app at xcode (general tab) 148 | * enable remote notification capabilities 149 | * add `GoogleService-Info.plist` to the app folder in xcode 150 | 151 | ``` 152 | // (optional) turn off `swizzling` in the `info.plist` 153 | FirebaseAppDelegateProxyEnabled 154 | NO 155 | ``` 156 | 157 | > Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again. 158 | 159 | ### Prevent auto initialization 160 | 161 | If you need to implement opt-in behavior, you can disable the auto initialization of the library by following the [Firebase docs](https://firebase.google.com/docs/cloud-messaging/ios/client#prevent_auto_initialization). 162 | 163 | ### SPM setup (iOS 15.0+) 164 | 165 | __First ensure all your dependencies are compatible with SPM. Otherwise, stick to the Cocoapods installation steps.__ 166 | 167 | You can also install the plugin using Swift Package Manager (SPM) instead of CocoaPods. 168 | To do so, you don't need to install CocoaPods (steps 1 & 2), but you'll need to configure capacitor to use SPM: 169 | * to add iOS target: `npx cap add ios --packagemanager SPM` 170 | * to migrate an existing target: `npx cap spm-migration-assistant` (with capacitor 7.4.0+). 171 | 172 | You can find more info in the official [capacitor docs](https://capacitorjs.com/docs/ios/spm). 173 | 174 | ## Android setup 175 | 176 | - `ionic start my-cap-app --capacitor` 177 | - `cd my-cap-app` 178 | - `mkdir www && touch www/index.html` 179 | - `npx cap add android` 180 | - `npm install --save @capacitor-community/fcm` 181 | - `npx cap sync android` _(always do sync after a plugin install)_ 182 | - `npx cap open android` 183 | - add `google-services.json` to your `android/app` folder 184 | 185 | Now you should be set to go. Try to run your client using `ionic cap run android --livereload`. 186 | 187 | > Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again. 188 | 189 | ### Variables 190 | 191 | This plugin will use the following project variables (defined in your app's `variables.gradle` file): 192 | 193 | - `$firebaseMessagingVersion` version of `com.google.firebase:firebase-messaging` (default: `23.1.2`) 194 | 195 | ### Prevent auto initialization 196 | 197 | If you need to implement opt-in behavior, you can disable the auto initialization of the library by following the [Firebase docs](https://firebase.google.com/docs/cloud-messaging/android/client#prevent-auto-init). 198 | 199 | ## Example 200 | 201 | - https://github.com/capacitor-community/fcm/tree/master/example 202 | 203 | ## License 204 | 205 | MIT 206 | 207 | ## Contributors ✨ 208 | 209 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 |
stewones
stewones

💻 📖
Daniel Pereira
Daniel Pereira

💻 📖
Priyank Patel
Priyank Patel

💻
Nikolas
Nikolas

🚧
Ben Schattinger
Ben Schattinger

💻
James Manners
James Manners

💻
Borja Rodríguez
Borja Rodríguez

🚧
Karrlllis
Karrlllis

📖
jamesmah
jamesmah

💻
Josh Sharpe
Josh Sharpe

🚧
Mantas Šimkūnas
Mantas Šimkūnas

💻 📖
Olivier Overstraete
Olivier Overstraete

🚧
Hemang Kumar
Hemang Kumar

💻 🚧
Luca Ban
Luca Ban

📖
Alex Griffith
Alex Griffith

💻 🚧
bdirito
bdirito

🚧
Ryan
Ryan

🚧
Josué Moreno
Josué Moreno

💻
Marc
Marc

🚧
Florian Gyger
Florian Gyger

💻
jcesarmobile
jcesarmobile

💬 📖 🚧
Rami Khafagi
Rami Khafagi

💻
Bittor Poza
Bittor Poza

💻
Vishal Isharani
Vishal Isharani

🚧 💻
Shunta KARASAWA
Shunta KARASAWA

🚧
Chris Weight
Chris Weight

🚧
Vincent Mahnke
Vincent Mahnke

🚧
tompidom
tompidom

🚇
258 | 259 | 260 | 261 | 262 | 263 | 264 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 265 | --------------------------------------------------------------------------------