Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install #4

Open
newuser44 opened this issue Dec 4, 2020 · 2 comments
Open

Can't install #4

newuser44 opened this issue Dec 4, 2020 · 2 comments

Comments

@newuser44
Copy link

Trying to check out the code I'm using ionic 3.

ionic cordova plugin add https://github.com/lucky3491/cordova-plugin-wkwebview-inject-cookie

cordova plugin add https://github.com/lucky3491/cordova-plugin-wkwebview-inject-cookie --save
Installing "cordova-plugin-wkwebview-inject-cookie" for ios
Failed to install 'cordova-plugin-wkwebview-inject-cookie': Error: Unable to load Platform API from /Users/work/WebKit/gf-mobileapps/platforms/ios/cordova/Api.js:
Cannot find module 'unorm'
Require stack:

  • /Users/work/WebKit/mobile-app/platforms/ios/cordova/Api.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/index.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/plugman.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/cordova-lib.js
  • /usr/local/lib/node_modules/cordova/src/help.js
  • /usr/local/lib/node_modules/cordova/src/cli.js
  • /usr/local/lib/node_modules/cordova/bin/cordova
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/Users/work/WebKit/mobile-mobileapps/platforms/ios/cordova/Api.js:24:13)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)

Unable to load Platform API from /Users/work/WebKit/mobileapps/platforms/ios/cordova/Api.js:
Cannot find module 'unorm'
Require stack:

  • /Users/work/WebKit/mobileapps/platforms/ios/cordova/Api.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/index.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/plugman.js
  • /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/cordova-lib.js
  • /usr/local/lib/node_modules/cordova/src/help.js
  • /usr/local/lib/node_modules/cordova/src/cli.js
  • /usr/local/lib/node_modules/cordova/bin/cordova

Still trying to get my head around why this plugin is going to fix.
Two problems I know of with WKWebView and cookies.
Javascript code - documents.cookies. that doesn't work and this plugin I don't think will fix that. Seems like some rule in iOS WKWebView that does not allow cookies to be set from with in code. Am I correct on that?

Second issue is that first time opening the app and doing some type of login, when cookies are being sent from the API they don't get saved. Problem with next call because cookies aren't there.

Is this going to fix that? Login cookies will just work, OR
Do we still have to manually get the cookies from login and set them up ourselves? We can't use the "Set-Cookie" option from back end API and would have to pass them down in customs header?

I just want login cookies to work again with no backend work.

@newuser44
Copy link
Author

Seems like I needed to add and remove iOS took care of the problem.
Now I can't figure out how to use it, or validate if it's working.

The code has its own class that I created to match it.

 if (this.platform.is('ios')) {

          let cookiesArray = Array<cookiesClass>();
          let cookiesValue  = new cookiesClass();

          //cookiesValue.domain = ENV.wsUrl;
          cookiesValue.path = "/"
          cookiesValue.name = "init";
          cookiesValue.value = "init";
          cookiesValue.secure = true;

          cookiesArray.push(cookiesValue);

          // cookiesArray[i].domain,
          // cookiesArray[i].path ? cookiesArray[i].path : '/',
          // cookiesArray[i].name,
          // cookiesArray[i].value,
          // cookiesArray[i].secure ? cookiesArray[i].secure : true,
          // cookiesArray[i].maxAge ? cookiesArray[i].maxAge : 2592000


          wkWebView.injectCookie(cookiesArray, this.cookiesSuccess(), this.cookiesFail());

Trying to set up the values. I'm confused what should be set for domain?
Should I use some localhost domain ? (That is all I can see when debugging in safari).
This leaves domain empty is supposed to use local host?
Do I use this ionic://localhost ?

Says to use the api I'm calling. I have tried that too no luck.

Also not sure if there is a way for me to view the cookie I just set?
Please help. Stuck!

@aronAtWex
Copy link

I don't think this plugin works with ios 14. If I realized that (my own fault) I probably wouldn't not have tried this. It seemed like the best/easiest solution. Still don't know why Cordova or ionic have any official fix for this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants