cwbudde / cordova-plugin-wkwebview-inject-cookie Goto Github PK
View Code? Open in Web Editor NEWInjects a cookie in order to start the sync processs with wkWebView
License: Apache License 2.0
Injects a cookie in order to start the sync processs with wkWebView
License: Apache License 2.0
secure ? secure : true
Such condition prevent any values but true
Hello, I'm using this amazing plugin for sync cookies between main app and iframes inside the app.
With 2 code lines I make everything work.... since now.
With ios 14 the plugin seems to have no effect any more but still working on ios 13 and ios 12 (tested on ios emulator and the new version of xcode).
Is there any way to make this little gem works on ios 14 too?
I expect that customers can be a little disappointed after they update ios the the new version...
Thanks,
Marco
Re: apache/cordova-plugin-inappbrowser#509 (comment)
The linked issue from InAppBrowser explains: "In iOS cookies are not persistent once app is exited and restarted. This creates problem with hosted web app saving cookies or local storage."
And the linked issue comment itself is from a user who attempted to use cordova-plugin-wkwebview-cookie-sync
but to no effect. I'm also using this plugin which has been working well, except that when exiting the app to the system browser, through InAppBrowser, the user is immediately logged out of the app, loses session/cookies, and returns to find the app landing/login screen, rather than where they originally exited from.
If cordova-plugin-wkwebview-cookie-sync could set an expiration, arbitrarily far into the future (e.g. "12/31/9999") it should solve this problem (re: apache/cordova-plugin-inappbrowser#509 (comment)).
"... By setting an explicit expiration date on the cookie returned by the server this causes the browser to treat it as persistent."
Could you advise on how to set the expiration? (Either hardcoded in the plugin, or as an argument when calling "injectCookie").
I used the following code:
wkWebView.injectCookie('example.com');
When the app is installed and launch the first time, the cookie is not set. The problem is gone when I close and restart the app.
Looks like someone else has the same problem: https://bugs.webkit.org/show_bug.cgi?id=213120
Please add license information to make it easier to use this great plugin
I am using the latest Ionic4, with angular7, there I am using normal httpClient with Obervables as responses. I added your plugin and setup the inject cookie, but still getting seeing that the backend is not receiving the keys, any idea where to look?
Hello,
i'm trying to make cookies work on my iOS cordova app using your cookie injection plugin combined with Oracle's WKWebView plugin (https://github.com/oracle/cordova-plugin-wkwebview-file-xhr). I've called the cookie plugin setup as it's on the documentation:
document.addEventListener('deviceready', () => { wkWebView.injectCookie('mydomain.com/mypath'); });
And then using CookieMaster plugin (https://github.com/RTK/cordova-cookie-emperor), i'm trying to set the cookies but they're not set at all.
Can you please describe if the plugin has to be combined with some specific WKWebView cordova plugin other than Oracle's (i've already tried all available WKWebView plugins) or if it's something wrong with the plugin call? Thank you in advance.
I installed the plugin, and modified the file ".//platforms/ios/App.xcarchive/Products/Applications/ App.app/www/js/index.js" by adding the line:
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
this.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
// *** add the cookie handling line (IP is the computer running the backend server): ***//
wkwebview.injectCookie('http://10.204.155.132:8888/');
console.log('Received Event: ' + id);
}
};
app.initialize();
The question is do I put the line into the correct file or the IP is not the way to be used for myDomain?
This plugin was very useful, however it has recently stopped working after updating ionic and ios dependencies on the ios emulator.
When debugging using safari:
Environment
Ionic:
Ionic CLI : 5.4.13 (/Users/zeer/Documents/KitchenMate/kitchenmate/node_modules/ionic)
Ionic Framework : unknown
@ionic/v1-toolkit : 2.0.18
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : ios 5.1.1
Cordova Plugins : cordova-plugin-ionic 5.4.6, cordova-plugin-ionic-webview 4.1.3, (and 7 other plugins)
Utility:
cordova-res : 0.8.1
native-run : 0.3.0
System:
Android SDK Tools : 26.1.1 (/Users/zeer/Library/Android/sdk)
ios-deploy : 1.10.0
ios-sim : 8.0.2
NodeJS : v10.15.3 (/Users/zeer/.nvm/versions/node/v10.15.3/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 11.3 Build version 11C29
Plugins
cordova-plugin-android-permissions 1.0.2 "Permissions"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-ionic 5.4.6 "cordova-plugin-ionic"
cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-wkwebview-inject-cookie 1.0.2 "WKWebViewInjectCookie"
ionic-plugin-deeplinks 1.0.20 "Ionic Deeplink Plugin"
onesignal-cordova-plugin 2.8.1 "OneSignal Push Notifications"
Using cordova-fetch for cordova-plugin-wkwebview-inject-cookie@^1.0.2
Adding cordova-plugin-wkwebview-inject-cookie project...
Unable to load PlatformApi from platform. Error: Cannot find module
'D:\Projects\Final\2\node_modules\cordova-plugin-wkwebview-inject-cookie'
Unhandled error. (The platform "cordova-plugin-wkwebview-inject-cookie" does not appear to be a valid cordova platform. It is missing API.js. cordova-plugin-wkwebview-inject-cookie not supported.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.