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

[4.2.0] Platform not recognizing ios #556

Closed
miqmago opened this issue Apr 28, 2020 · 7 comments
Closed

[4.2.0] Platform not recognizing ios #556

miqmago opened this issue Apr 28, 2020 · 7 comments

Comments

@miqmago
Copy link

miqmago commented Apr 28, 2020

Tested on real iPad 13.1.3:

this.platform.is('ios')

Returns always false.

On the other hand:

this.device.platform === 'iOS';

Evals true

@jcesarmobile
Copy link
Member

I can't reproduce

And in any case, it would be an ionic bug, not a plugin bug, since the platform logic is implemented there

@sparsematrix
Copy link

I also see this issue. On 5.0.0 I have the following platforms listed when running on an ipad: cordova,mobile,hybrid. With version 4.1.3 I see: ipad,ios,tablet,cordova,mobile,hybrid. As such my app uses material icons and has interesting (incorrect) font choices when run on iPad with 5.0.0. If I simply go back to the 4.1.3 plugin everything looks fine.

@sparsematrix
Copy link

This is an issue with this plugin, not something with the platform. If the platform was wrong then you were supporting it and making people dependent on this error. Perhaps Ionic 5 does not suffer from this issue, but 4.x does.

These lines were removed from CDVWKWebViewEngine.m in 4.2.0 and their absence is the cause:
if ([self.viewController isKindOfClass:[CDVViewController class]]) {
wkWebView.customUserAgent = ((CDVViewController*) self.viewController).userAgent;
}

Perhaps you needed to else if that on your new overrideUserAgent check on line 279? Doing that solves the problem for me:

if (overrideUserAgent != nil) {
    wkWebView.customUserAgent = overrideUserAgent;
} else if ([self.viewController isKindOfClass:[CDVViewController class]]) {
    wkWebView.customUserAgent = ((CDVViewController*) self.viewController).userAgent;
}

@jcesarmobile
Copy link
Member

Then report a new issue and provide a sample app where can be reproduced.
If somebody report an issue, doesn’t provide a sample app nor any details about ionic or plugin versions, I try on a new app and I can’t reproduce I close it.

@oddcb
Copy link

oddcb commented Oct 14, 2020

Hi. Just to add I'm currently upgrading an app with this plugin version 1.2.1 to version 5.0.0 with Ionic 3.9.9.
With version 5.0.0 I'm experiencing the same bug as reported here.

Ionic v3 uses the userAgent to set the platform and then set appropriate styling.

See https://github.com/ionic-team/ionic-v3/blob/master/src/platform/platform-registry.ts#L123 isMatch under 'ios' and isPlatformMatch https://github.com/ionic-team/ionic-v3/blob/master/src/platform/platform.ts#L893 - those determines the Platform by searching the user agent string for ipad/ios etc. With 5.0.0 and 4.2.0 the user agent does noe contain those strings any more.

I don't know if this should be fixed/changed in this plugin or in Ionic 3 (which seems abandoned), or something we have to patch together ourselves for Ionic 3. There are several issues reported in the v3 repository:

The documentation for this plugin should at least be updated to say it's not compatible with Ionic 3 until a fix or workaround is available

On actual device on iPad 6th gen - iPadOS 14 (18A373 - I have the public beta profile installed, but I assume this is the 14 GM) window.navigator.userAgent:

1.2.1: Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

4.1.3: Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

4.2.0: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

5.0.0: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

ionic info with 5.0.0 installed:

Ionic:

   Ionic CLI          : 6.11.12 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework    : ionic-angular 3.9.9
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-webview 5.0.0, (and 26 other plugins)

Utility:

   cordova-res (update available: 0.15.1) : 0.10.0
   native-run (update available: 1.2.1)   : 0.3.0

System:

   ios-sim : 8.0.2
   NodeJS  : v14.13.0 (/usr/local/Cellar/node/14.13.0/bin/node)
   npm     : 6.14.8
   OS      : macOS Catalina
   Xcode   : Xcode 12.0.1 Build version 12A7300

@fbrun
Copy link

fbrun commented Aug 26, 2021

This is an issue with this plugin, not something with the platform. If the platform was wrong then you were supporting it and making people dependent on this error. Perhaps Ionic 5 does not suffer from this issue, but 4.x does.

These lines were removed from CDVWKWebViewEngine.m in 4.2.0 and their absence is the cause:
if ([self.viewController isKindOfClass:[CDVViewController class]]) {
wkWebView.customUserAgent = ((CDVViewController*) self.viewController).userAgent;
}

Perhaps you needed to else if that on your new overrideUserAgent check on line 279? Doing that solves the problem for me:

if (overrideUserAgent != nil) {
    wkWebView.customUserAgent = overrideUserAgent;
} else if ([self.viewController isKindOfClass:[CDVViewController class]]) {
    wkWebView.customUserAgent = ((CDVViewController*) self.viewController).userAgent;
}

Hi I tried this solution, but under iOS 14, i have the error IOS build failed for IOS 14 - Property ‘userAgent’ not found on object of type ‘CDVViewController *’

@KarunaLakshman
Copy link

Hi, ionic-v3 repo is now read-only, so I'm posting my solution here, which could help those using cordova-ios@6+ andionic-v3. Setting ContentMode to mobile corrected the user-agent.

<preference name="PreferredContentMode" value="mobile"/>

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

6 participants