diff --git a/firebase-messaging-sw.js b/firebase-messaging-sw.js index aa3917c40..138a7fd1c 100644 --- a/firebase-messaging-sw.js +++ b/firebase-messaging-sw.js @@ -1,11 +1,29 @@ - if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('./firebase-messaging-sw.js') - .then(function(registration) { - console.log('Registration successful, scope is:', registration.scope); - }).catch(function(err) { - console.log('Service worker registration failed, error:', err); - }); - } +if ("serviceWorker" in navigator) { + navigator.serviceWorker + .register("./firebase-messaging-sw.js") + .then(function(registration) { + console.log("Registration successful, scope is:", registration.scope); + messaging.getToken({vapidKey: 'BEuyzkUKcx4FSs-6GaIz_si2oV5Ut7e5ZEtcrVvr5L_tMVWZtS1NTqdtQkih5QCt2FZKuRUxZIaLm5GaxI6nJEw', serviceWorkerRegistration : registration }) + .then((currentToken) => { + if (currentToken) { + console.log('current token for client: ', currentToken); + + // Track the token -> client mapping, by sending to backend server + // show on the UI that permission is secured + } else { + console.log('No registration token available. Request permission to generate one.'); + + // shows on the UI that permission is required + } + }).catch((err) => { + console.log('An error occurred while retrieving token. ', err); + // catch error while creating client token + }); + }) + .catch(function(err) { + console.log("Service worker registration failed, error:" , err ); + }); + } // Scripts for firebase and firebase messaging diff --git a/ios/App/App/config.xml b/ios/App/App/config.xml index 43b503a74..b8563b6fc 100644 --- a/ios/App/App/config.xml +++ b/ios/App/App/config.xml @@ -6,6 +6,10 @@ + + + + diff --git a/ios/App/Podfile b/ios/App/Podfile index ee4cde511..6089bc9aa 100644 --- a/ios/App/Podfile +++ b/ios/App/Podfile @@ -10,11 +10,12 @@ def capacitor_pods pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app' + pod 'CapacitorBrowser', :path => '..\..\node_modules\@capacitor\browser' pod 'CapacitorCamera', :path => '..\..\node_modules\@capacitor\camera' + pod 'CapacitorFilesystem', :path => '..\..\node_modules\@capacitor\filesystem' pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics' pod 'CapacitorKeyboard', :path => '..\..\node_modules\@capacitor\keyboard' pod 'CapacitorNetwork', :path => '..\..\node_modules\@capacitor\network' - pod 'CapacitorFilesystem', :path => '..\..\node_modules\@capacitor\filesystem' pod 'CapacitorPushNotifications', :path => '..\..\node_modules\@capacitor\push-notifications' pod 'CapacitorVoiceRecorder', :path => '..\..\node_modules\capacitor-voice-recorder' pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins' diff --git a/package-lock.json b/package-lock.json index ac401ff1e..d026f83f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2040,6 +2040,11 @@ "resolved": "https://registry.npmjs.org/@capacitor/app/-/app-1.0.5.tgz", "integrity": "sha512-U0dAw1CAjKyguSRxKDabszsQ4dj679RnxaUZrSHDR5Jnt5x308oQuKXFP++wnMBbw72D02iqjG0a+/Ujye7C9g==" }, + "@capacitor/browser": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@capacitor/browser/-/browser-1.0.6.tgz", + "integrity": "sha512-ZDx+HNPRQZKHpWxbYEyDz34Ge4fwhiiGg2UEnA+ol+pmdvHyYxw/c8HafCEVRJutHrXcVdSNoBNAeEPkQeabrQ==" + }, "@capacitor/camera": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@capacitor/camera/-/camera-1.2.0.tgz", @@ -7894,6 +7899,11 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-okhttp/-/cordova-plugin-okhttp-2.0.0.tgz", "integrity": "sha1-6GT2C//zQqHZJHeugvckmqYIXIA=" }, + "cordova-plugin-screen-orientation": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/cordova-plugin-screen-orientation/-/cordova-plugin-screen-orientation-3.0.2.tgz", + "integrity": "sha512-2w6CMC+HGvbhogJetalwGurL2Fx8DQCCPy3wlSZHN1/W7WoQ5n9ujVozcoKrY4VaagK6bxrPFih+ElkO8Uqfzg==" + }, "cordova-plugin-splashscreen": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/cordova-plugin-splashscreen/-/cordova-plugin-splashscreen-5.0.4.tgz", diff --git a/package.json b/package.json index 517868044..874b58b5d 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@angular/router": "~12.1.2", "@capacitor/android": "3.3.1", "@capacitor/app": "^1.0.5", + "@capacitor/browser": "1.0.6", "@capacitor/camera": "^1.2.0", "@capacitor/core": "^3.3.0", "@capacitor/filesystem": "^1.0.6", @@ -93,6 +94,7 @@ "cordova-plugin-dbcopy": "git+https://github.com/an-rahulpandey/cordova-plugin-dbcopy.git", "cordova-plugin-filepath": "^1.5.8", "cordova-plugin-okhttp": "^2.0.0", + "cordova-plugin-screen-orientation": "^3.0.2", "cordova-res": "^0.15.3", "cordova-sqlite-storage": "^5.1.0", "cross-env": "^7.0.3",