Adding web notifications

This commit is contained in:
Eudes Inácio
2021-11-05 10:13:22 +01:00
parent 1d58ef0615
commit bfad677f35
5 changed files with 774 additions and 79 deletions
+23 -37
View File
@@ -1,42 +1,28 @@
function wlCommonInit() {
if(window['WLAuthorizationManager']) {
if(window['WLAuthorizationManager'].obtainAccessToken) {
window['WLAuthorizationManager'].obtainAccessToken("").then(
(token) => {
console.log('MobileFirst Server connect: Success ' + token);
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
WLResourceRequest.GET
);
resourceRequest.setQueryParameter("name", "world");
resourceRequest.send().then(
(response) => {
// Will display "Hello world" in an alert dialog.
console.log("Connect with JavaAdapter Success: " + response.responseText);
//this.MFPushNotification();
},
(error) => {
alert("Connect with JavaAdapter Failure: " + JSON.stringify(error));
}
);
}, (error) => {
console.log('MobileFirst Server connect: failure ' + error.responseText);
console.log(JSON.stringify(error))
/* this.zone.run(() => {
alert("Bummer...");
alert("Failed to connect to MobileFirst Server");
}); */
}
);
}
}
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.2.0/firebase-app.js";;
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.2.0/firebase-analytics.js";
import { getMessaging, getToken } from "https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY",
authDomain: "gabinete-digital-2020.firebaseapp.com",
databaseURL: "https://gabinete-digital-2020.firebaseio.com",
projectId: "gabinete-digital-2020",
storageBucket: "gabinete-digital-2020.appspot.com",
messagingSenderId: "800733765231",
appId: "1:800733765231:web:28e7792ab150006513779a",
measurementId: "G-8QN4BLZ8XK"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const messaging = getMessaging(app);
}
getToken({vapidKey: "BEuyzkUKcx4FSs-6GaIz_si2oV5Ut7e5ZEtcrVvr5L_tMVWZtS1NTqdtQkih5QCt2FZKuRUxZIaLm5GaxI6nJEw"});