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

iOS Error #95

Closed
tjelz opened this issue May 13, 2020 · 10 comments
Closed

iOS Error #95

tjelz opened this issue May 13, 2020 · 10 comments

Comments

@tjelz
Copy link

tjelz commented May 13, 2020

Description

Hello, I seem to be having an issue with iOS and opening the webpage to login, it is all working fine on the web and I have not yet managed to test it for Android.

When I press my login button which calls the Authenticate method, on the web a browser window will show to ask for login credentials, on iOS, no webpage is shown, only an error in XCode.

The error in XCode when I attempt to call the authenticate method is:

 [error] - ERROR {"line":101020,"column":51,"sourceURL":"capacitor://localhost/vendor-es2015.js"}

This goes to this line of code (first line):

else if (this.windowHandle.closed && !this.windowClosedByPlugin) {
      clearInterval(this.intervalId);
      reject(new Error("USER_CANCELLED"));
}

I am using the latest iOS Simulator (iPhone 11).

I can only assume that 'windowHandle' is null for some reason?

Capacitor version:

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 2.1.0

@capacitor/core: 2.1.0

@capacitor/android: 2.1.0

@capacitor/electron: 2.1.0

@capacitor/ios: 2.1.0

Installed Dependencies:

@capacitor/electron not installed

@capacitor/ios 2.0.2

@capacitor/core 2.0.2

@capacitor/cli 2.0.2

@capacitor/android 2.0.2

[success] Android looking great! 👌
Found 1 Capacitor plugin for ios:
@byteowls/capacitor-oauth2 (2.0.0)
[success] iOS looking great! 👌

Library version:

  • 2.0.0

OAuth Provider:

  • Other: Custom IdentityServer4

Your Plugin Configuration

export const oauth2Options = {
  authorizationBaseUrl: "aaa",
  accessTokenEndpoint: "aaa",
  scope: "aaa",
  resourceUrl: "",
  pkceEnabled: true,
  web: {
    appId: "mobile",
    responseType: "code", // implicit flow
    redirectUrl: "http://localhost:1234/signin-oidc",
    windowOptions: "height=600,left=0,top=0"
  },
  android: {
    appId: "mobile",
    responseType: "code", // if you configured a android app in google dev console the value must be "code"
    redirectUrl: "aaa:/" // package name from google dev console
  },
  ios: {
    appId: "mobile",
    responseType: "code", // if you configured a ios app in google dev console the value must be "code"
    redirectUrl: "aaa:/" // Bundle ID from google dev console
  }
}
@tjelz tjelz changed the title iOS iOS Error May 13, 2020
@bialabs
Copy link

bialabs commented May 13, 2020

same error here. Auth works on web and on iOS i get infinite

[Error] ERROR TypeError: null is not an object (evaluating 'this.windowHandle.closed')

@tjelz
Copy link
Author

tjelz commented May 14, 2020

Update, It seems to work (in terms of displaying a webpage) on Android, so the error seems to be just for iOS.

@moberwasserlechner
Copy link
Collaborator

moberwasserlechner commented May 16, 2020

Hi,

the line this.windowHandle.closed you refer to is from the web implementation not the iOS one.

As you get this in XCode there might be something wrong with your config.

  • Delete your node_modules dir
  • Delete your package-lock.json
  • Run npm i and build for iOS
  • Run npx cap sync ios
  • Clean you XCode build. (I do that every time I start XCode because of XCode's agressive caching)

If these steps do not help, please provide a sample repository so I can have a look.

@moberwasserlechner
Copy link
Collaborator

This issue is maybe a duplicate of #94 because it seems that the app and the Identity Server runs on the same host.

@bialabs
Copy link

bialabs commented May 16, 2020

Hi,

the line this.windowHandle.closed you refer to is from the web implementation not the iOS one.

As you get this in XCode there might be something wrong with your config.

  • Delete your node_modules dir
  • Delete your package-lock.json
  • Run npm i and build for iOS
  • Run npx cap sync ios
  • Clean you XCode build. (I do that every time I start XCode because of XCode's agressive caching)

If these step do not help, please provide a samble repository so I can have a look.

tried your steps and do not help
still this error on safari web inspector

[Error] ERROR – TypeError: null is not an object (evaluating 'this.windowHandle.closed')

i'll provide a sample repo

@tjelz
Copy link
Author

tjelz commented May 18, 2020

Hello,

Running the sync command (npx cap sync ios) actually returns the following error:

[!] CocoaPods could not find compatible versions for pod "OAuthSwift":
  In Podfile:
    ByteowlsCapacitorOauth2 (from `../../node_modules/@byteowls/capacitor-oauth2`) was resolved to 2.0.0, which depends on
      OAuthSwift (= 2.1.0)

How would I resolve this?

@moberwasserlechner
Copy link
Collaborator

Hi,

TL;DR
You have to update your project's pods.

These are the steps, that I do if there are missing iOS dependencies.

  • rm -rf node_modules
  • npm i
  • npx cap update ios
  • Go to ios/App
    • Clean the cocoapod cache: pod cache clean --all
    • Update the cocoapod sudo gem install cocoapods
    • Update the local cocoapod repository with the changes from the master pod update
    • If that does not work remove the Podfile.lock and run pod install

If this doesnot work, plz provide a sample repo.

@tjelz
Copy link
Author

tjelz commented May 18, 2020

Okay I can confirm that has now made the iOS app work in terms of displaying the browser when pressing authenticate.

Thank you for your help, I will leave this ticket open for a little in-case the other person has not got it working.

@moberwasserlechner
Copy link
Collaborator

@tomfebry I think it is save to close this one, as your problem is solved and the other user person @bialabs does not reply.

@tjelz
Copy link
Author

tjelz commented May 26, 2020

@moberwasserlechner Agreed.

@tjelz tjelz closed this as completed May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants