Closed gareth-johnstone closed 5 years ago
I understand that this plugin only has support for Android and iOS, but it is possible to combine it with web technology. In my case using ionic I have detected the platform and launched the web or cordova method. https://firebase.google.com/docs/cloud-messaging/js/client
You have a great tutorial about Ionic PWA and Web Push Notifications https://medium.com/@david.dalbusco/add-web-push-notifications-to-your-ionic-pwa-358f6ec53c6f
import { Platform } from '@ionic/angular';
import {firebase} from '@firebase/app';
@Component({...})
export class MyPage {
constructor(public platform: Platform) {
if(platform.is('pwa'){
if (firebase.messaging.isSupported()) {
const messaging = firebase.messaging();
await messaging.requestPermission();
const token = await messaging.getToken();
console.log('User token: ', token);
} else {
alert("Your browser is not supported");
}
}else{
//Cordova plugin function
window.FirebasePlugin.getToken(function(token) {
// save this server-side and use it to push notifications to this device
console.log(token);
}, function(error) {
console.error(error);
});
}
}
}
I hope I've helped!
I created a index.html in xcode and i can get the push notifications to work if i have my files local to the app (so in the www folder in xcode)
However, none of the push notification code works on the hosted application that i want to have my cordova app pointed to. (window.firebaseplugin is undefined in that instance
So im at a loss as to how to get IOS push notifications in my cordova app that points to a PWA that is hosted on a server.
@gareth-johnstone this plugin is designed to support Cordova apps running on a native Android or iOS platform so your requirement to have a hosted PWA access the plugin API is beyond the scope of what this plugin is intended for.
Hi guys, it could be that im going about this all wrong - and sorry i know this is the wrong style of issue for what im asking, but i couldnt find the "im probably being stupid, can you help a guy out", issue type
I currently have a Progressive Web App (PWA) (hosted on a server) that I'm pointing my cordova app at - in the PWA im putting the
window.FirebasePlugin
but its showing as undefinedIs this because its not available there and instead only available to the local content - if so, any way around this so i can pass the token back to my webapp?
Bug report
Current behavior:
window.firebaseapp is undefined
Expected behavior: window.firebaseplugin is available in my progressive web app
Steps to reproduce:
Screenshots
Environment information
9.0.0
cordova platform ls
Runtime issue
Android build issue:
node -v
ls platforms/android/.gradle
android:targetSdkVersion
inAndroidManifest.xml
sdkmanager --list | sed -e '/Available Packages/q'
iOS build issue:
node -v
Related code:
Console output
console output
``` // Paste any relevant JS/native console output here ```**Other information:**