Phonegap windows phone 8 height content because of status bar - jquery-mobile

I have an issue with phonegap on windows phone 8. I want to have my app with the status bar, so I set:
<preference name="fullscreen" value="false" />
in "config.xml" file but my app contains a footer and this footer are shift because of status bar.
Anybody can help to fix that ?
I already set the "meta viewport" but no change.

try this .... set viewport in css file
#-ms-viewport{
width:device-width;
}
#-ms-viewport{
height:device-height;
}
http://trentwalton.com/2013/01/16/windows-phone-8-viewport-fix/
i developed one app using phonegap i used all solutions with status bar but this problem not solved. i had used "plugin name="org.apache.cordova.statusbar" version="0.1.4" plugin in config.xml file. this problem come only for windows so i hide status bar only for windows
<script>
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
function startEvents() {
StatusBar.hide();
}
}
</script>

Related

Statusbar in Cordova-ios stays translucent

I am using the cordova status bar plugin and the statusbar is translucent and white. I am developing for iOS 11 witht he newest Version of macOS and xCode.
I researched the errors but none of the fixes proposed helped me.
Adding viewport-fit=cover to the meta tag at the index.html did not work.
Adding the feature tag with ios-package, as mentioned in the docs, to www/config.xml as a child to widget.
Adding the preference tag with StatusBarBackgroundColor and Overlay to the config.xml (as a child to widget and to ios) and www/config.xml did not works.
Using it in Code with the StatusBar global var inside a cordova.platformId = 'ios', has no effect.
In the end the app starts with a black bottom, the black bottom is gone and then there is the translucent status bar.
Adding this to my config.xml solved the problem for me:
<gap:plugin name="cordova-plugin-statusbar" source="npm"/>
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#ffffff" />
<preference name="StatusBarStyle" value="default" />
So, i have ran into the similar issue, that i neede to my statusbar to overlay the WebView and be white with 50% transparency. So i investigated the plugin code and noticed, that if status bar overlays WebView - then the plugin ingores the background settings.
So the only solution was to fork the original plugin and modify it. You can take it here:
https://github.com/Fomenko-developer/cordova-plugin-statusbar
Installation:
cordova plugin add https://github.com/Fomenko-developer/cordova-plugin-statusbar.git

Cordova app not displaying correctly on iPhone X (Simulator)

I tested my Cordova-based app yesterday on the iPhone X Simulator in Xcode 9.0 (9A235) and it didn't look good.
Firstly, instead of filling the full screen area, there was a black area above and below the app content.
And worse, between the app content and the black was two white bars.
Adding cordova-plugin-wkwebview-engine so Cordova renders using WKWebView (not UIWebView) fixes the white bars.
By my app is not migrated from UIWebView to WKWebView due to performance and memory leak issues when using cordova-plugin-wkwebview-engine which occur when loading images downloaded from Inapp Purchase hosted content into an HTML5 canvas (direct file:// access by the Webview is not possible due to security restrictions in WKWebView so the image data must be loaded via cordova-plugin-file).
These screenshots show a test app with a blue background set on the <body>.
Above and below UIWebView, you can see the white bars, but not with WKWebView:
(source: pbrd.co)
(source: pbrd.co)
Both Cordova Webviews exhibit the black areas when compared to a native app which fills the full screen area:
I found the solution to the white bars here:
Set viewport-fit=cover on the viewport <meta> tag, i.e.:
<meta name="viewport" content="initial-scale=1, width=device-width, height=device-height, viewport-fit=cover">
The white bars in UIWebView then disappear:
The solution to remove the black areas (provided by #dpogue in a comment below) is to use LaunchStoryboard images with cordova-plugin-splashscreen to replace the legacy launch images, used by Cordova by default. To do so, add the following to the iOS platform in config.xml:
<platform name="ios">
<splash src="res/screen/ios/Default#2x~iphone~anyany.png" />
<splash src="res/screen/ios/Default#2x~iphone~comany.png" />
<splash src="res/screen/ios/Default#2x~iphone~comcom.png" />
<splash src="res/screen/ios/Default#3x~iphone~anyany.png" />
<splash src="res/screen/ios/Default#3x~iphone~anycom.png" />
<splash src="res/screen/ios/Default#3x~iphone~comany.png" />
<splash src="res/screen/ios/Default#2x~ipad~anyany.png" />
<splash src="res/screen/ios/Default#2x~ipad~comany.png" />
<!-- more iOS config... -->
</platform>
Then create the images with the following dimensions in res/screen/ios (remove any existing ones):
Default#2x~iphone~anyany.png - 1334x1334
Default#2x~iphone~comany.png - 750x1334
Default#2x~iphone~comcom.png - 1334x750
Default#3x~iphone~anyany.png - 2208x2208
Default#3x~iphone~anycom.png - 2208x1242
Default#3x~iphone~comany.png - 1242x2208
Default#2x~ipad~anyany.png - 2732x2732
Default#2x~ipad~comany.png - 1278x2732
Once the black bars are removed, there's another thing that's different about the iPhone X to address: The status bar is larger than 20px due to the "notch", which means any content at the far top of your Cordova app will be obscured by it:
Rather than hard-coding a padding in pixels, you can handle this automatically in CSS using the new safe-area-inset-* constants in iOS 11.
Note: in iOS 11.0 the function to handle these constants was called constant() but in iOS 11.2 Apple renamed it to env() (see here),
therefore to cover both cases you need to overload the CSS rule with both and rely on the CSS fallback mechanism to apply the appropriate one:
body{
padding-top: constant(safe-area-inset-top);
padding-top: env(safe-area-inset-top);
}
The result is then as desired: the app content covers the full screen, but is not obscured by the "notch":
I've created a Cordova test project which illustrates the above steps: webview-test.zip
Notes:
Footer buttons
If your app has footer buttons (as mine does), you will also need to apply safe-area-inset-bottom to avoid them being overlapped by the virtual Home button on iPhone X.
In my case, I couldn't apply this to <body> as the footer is absolutely positioned, so I needed to apply it directly to the footer:
.toolbar-footer{
margin-bottom: constant(safe-area-inset-bottom);
margin-bottom: env(safe-area-inset-bottom);
}
cordova-plugin-statusbar
The status bar size has changed on iPhone X, so older versions of cordova-plugin-statusbar display incorrectly on iPhone X
Mike Hartington has created this pull request which applies the necessary changes.
This was merged into the cordova-plugin-statusbar#2.3.0 release, so make sure you're using at least this version to apply to safe-area-insets
splashscreen
The LaunchScreen storyboard constraints changed on iOS 11/iPhone X, meaning the splashscreen appeared to "jump" on launch when using existing versions of the plugin (see here).
This was captured in bug report CB-13505, fixed PR cordova-ios#354 and released in cordova-ios#4.5.4, so make sure you're using a recent version of the cordova-ios platform.
device orientation
When using UIWebView on iOS 11.0, rotating from portrait > landscape > portrait causes the safe-area-inset not to be re-applied, causing the content to be obscured by the notch again (as highlighted by jms in a comment below).
Also happens if app is launched in landscape then rotated to portrait
This doesn't happen when using WKWebView via cordova-plugin-wkwebview-engine.
Radar report: http://www.openradar.me/radar?id=5035192880201728
Update: this appears to have been fixed in iOS 11.1
For reference, this is the original Cordova issue I opened which captures this: https://issues.apache.org/jira/browse/CB-13273
For a manual fix to an existing cordova project
The black bars
Add this to your info.plist file. Fixing the launch image is a separate issue i.e. How to Add iPhoneX Launch Image
<key>UILaunchStoryboardName</key>
<string>CDVLaunchScreen</string>
The white bars
Set viewport-fit=cover in the meta tag
<meta name="viewport" content="initial-scale=1, width=device-width, height=device-height, viewport-fit=cover">
There is 3 steps you have to do
for iOs 11 status bar & iPhone X header problems
1. Viewport fit cover
Add viewport-fit=cover to your viewport's meta in <header>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover">
Demo: https://jsfiddle.net/gq5pt509 (index.html)
Add more splash images to your config.xml inside <platform name="ios">
Dont skip this step, this required for getting screen fit for iPhone X work
<splash src="your_path/Default#2x~ipad~anyany.png" /> <!-- 2732x2732 -->
<splash src="your_path/Default#2x~ipad~comany.png" /> <!-- 1278x2732 -->
<splash src="your_path/Default#2x~iphone~anyany.png" /> <!-- 1334x1334 -->
<splash src="your_path/Default#2x~iphone~comany.png" /> <!-- 750x1334 -->
<splash src="your_path/Default#2x~iphone~comcom.png" /> <!-- 1334x750 -->
<splash src="your_path/Default#3x~iphone~anyany.png" /> <!-- 2208x2208 -->
<splash src="your_path/Default#3x~iphone~anycom.png" /> <!-- 2208x1242 -->
<splash src="your_path/Default#3x~iphone~comany.png" /> <!-- 1242x2208 -->
Demo: https://jsfiddle.net/mmy885q4 (config.xml)
Fix your style on CSS
Use safe-area-inset-left, safe-area-inset-right, safe-area-inset-top, or safe-area-inset-bottom
Example: (Use in your case!)
#header {
position: fixed;
top: 1.25rem; // iOs 10 or lower
top: constant(safe-area-inset-top); // iOs 11
top: env(safe-area-inset-top); // iOs 11+ (feature)
// or use calc()
top: calc(constant(safe-area-inset-top) + 1rem);
top: env(constant(safe-area-inset-top) + 1rem);
// or SCSS calc()
$nav-height: 1.25rem;
top: calc(constant(safe-area-inset-top) + #{$nav-height});
top: calc(env(safe-area-inset-top) + #{$nav-height});
}
Bonus: You can add body class like is-android or is-ios on deviceready
var platformId = window.cordova.platformId;
if (platformId) {
document.body.classList.add('is-' + platformId);
}
So you can do something like this on CSS
.is-ios #header {
// Properties
}
In my case where each splash screen was individually designed instead of autogenerated or laid out in a story board format, I had to stick with my Legacy Launch screen configuration and add portrait and landscape images to target iPhoneX 1125×2436 orientations to the config.xml like so:
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
<splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
After adding these to config.xml ("viewport-fit=cover" was already set in index.hml) my app built with Ionic Pro fills the entire screen on iPhoneX devices.
Just a note that the constant keyword use for safe-area margins has been updated to env for 11.2 beta+
https://webkit.org/blog/7929/designing-websites-for-iphone-x/
Fix for iPhone X/XS screen rotation issue
On iPhone X/XS, a screen rotation will cause the header bar height to use an incorrect value, because the calculation of safe-area-inset-* was not reflecting the new values in time for UI refresh. This bug exists in UIWebView even in the latest iOS 12. A workaround is inserting a 1px top margin and then quickly reversing it, which will trigger safe-area-inset-* to be re-calculated immediately. A somewhat ugly fix but it works if you have to stay with UIWebView for one reason or another.
window.addEventListener("orientationchange", function() {
var originalMarginTop = document.body.style.marginTop;
document.body.style.marginTop = "1px";
setTimeout(function () {
document.body.style.marginTop = originalMarginTop;
}, 100);
}, false);
The purpose of the code is to cause the document.body.style.marginTop to change slightly and then reverse it. It doesn't necessarily have to be "1px". You can pick a value that doesn't cause your UI to flicker but achieves its purpose.
I'm developing cordova apps for 2 years and I spent weeks to solve related problems (eg: webview scrolls when keyboard open). Here's a tested and proven solution for both ios and android
P.S.: I'm using iScroll for scrolling content
Never use viewport-fit=cover at index.html's meta tag, leave the app stay out of statusbar. iOS will handle proper area for all iPhone variants.
In XCode uncheck hide status bar and requires full screen and don't forget to select Launch Screen File as CDVLaunchScreen
In config.xml set fullscreen as false
Finally, (thanks to Eddy Verbruggen for great plugins) add his plugin cordova-plugin-webviewcolor to set statusbar and bottom area background color. This plugin will allow you to set any color you want.
Add below to config.xml (first ff after x is opacity)
<preference name="BackgroundColor" value="0xff088c90" />
Handle your scroll position yourself by adding focus events to input elements
iscrollObj.scrollToElement(elm, transitionduration ... etc)
For android, do the same but instead of cordova-plugin-webviewcolor, install cordova-plugin-statusbar and cordova-plugin-navigationbar-color
Here's a javascript code using those plugins to work on both ios and android:
function setStatusColor(colorCode) {
//colorCode is smtg like '#427309';
if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString(colorCode);
NavigationBar.backgroundColorByHexString(colorCode);
} else if (cordova.platformId == 'ios') {
window.plugins.webviewcolor.change(colorCode);
}
}
If you install newer versions of ionic globally you can run
ionic cordova resources and it will generate all of the splashscreen images for you along with the correct sizes.
Check out this link, sometimes may be helpful. I could solve the issue with the solution provided below.
https://github.com/apache/cordova-plugin-wkwebview-engine/issues/108
Add
[wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
before wkWebView.UIDelegate = self.uiDelegate; in CDVWebViewEngine.m

ionic status bar issue white - iOS

I am creating a mobile application with Ionic framework , When i test it with iOS device my status bar turn into white color after the application is fully loaded. I need to change the color from white to black. It works fine with Android Device.
This is the issue
I tried the following methods and nothing works
I made change to my config.xml file which was mentioned in many website as following
<preference name="StatusBarOverlaysWebView" value="true" />
<preference name="StatusBarBackgroundColor" value="#000000" />
<preference name="StatusBarStyle" value="lightcontent" />
I further added the statusbar native event handlers under my app.component.ts
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
statusBar.backgroundColorByHexString('#000000');
statusBar.show();
splashScreen.hide();
});
is there a better solution to solve this issue.
The HTML of this project
app.html
<ion-nav [root]="rootPage"></ion-nav>

Change statusbar color to white in Phonegap

I currently develop an app with phonegap and need to change the color of the statusbar to white text, right now it is black. I am testing on iOS 10 with the official app from PhoneGap.
The statusbar-plugin is installed, I already have checked via terminal (cordova plugin ls). Also, the term <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" /> is part of my config.xml.
I tried to change the statusbar with <preference name="StatusBarBackgroundColor" value="#000000" /> in my config.xml for example (I know this won't change the color to white, this was just a try to change the statusbar at all) – nothing has changed. None of the tips I found have changed anything – any ideas how to change the color?
Okay, I got it. Dumb mistake.
I deleted the default elements in index.html but forgot to edit the JS in the default index.js. After deleting the function which tried to change the missing element in my index, I finally was able to edit the StatusBar with StatusBar.styleLightContent();.

Cordova: How do you hide the status bar on the splash/launch screen?

I am trying to remove the status bar across my app with Cordova. I have tried <preference name="Fullscreen" value="true" /> but it looks like in iOS7 that does not work. (And iOS6 it left a black gap instead.)
I have since been using the StatusBar plugin and just firing StatusBar.hide(); at device ready, but this will not hide the status bar on the launch screen. Is there a way to hide the status bar across the entire app in iOS7 and not have to rewrite it each time I do a cordova build? Thank you.
It is not the full answer that makes Cordova do it automatically. But I went into my .plist file for the iOS build and added:
UIStatusBarHidden = true
UIViewControllerBasedStatusBarAppearance = false
This makes it behave the correct way and is not getting overwritten by Cordova when I do a build so it will work for now.
If anyone finds or knows of a better way to enforce these settings, feel free to post it and I will either update this answer or choose yours next time I notice it. Thank you!
Status Bar
To remove the status bar in iOS 7 use the following entries in the plist file.
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
In the configuration on XCode the following achieves the same
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO
Don't waste your time just do simple at the splash time/launch time status bar hide
Updated:
We can also inject the info.plist directly from config.xml.
<config-file parent="UIStatusBarHidden" platform="ios" target="*-Info.plist">
<true />
</config-file>
<config-file parent="UIViewControllerBasedStatusBarAppearance" platform="ios" target="*-Info.plist">
<false />
</config-file>
The first config will hide the status bar on the splash/lunch screen. The second config will hide the status bar after the splash/lunch screen.
Have you seen the following:
http://ionicframework.com/tutorials/fullscreen-apps/
First, we need to note this only works on Cordova (recommend v3.3.1) or another native UIWebView wrapper. If we use Cordova, we will need to install one plugin:
$ cordova plugin add org.apache.cordova.statusbar
Then, we will use Ionic's Platform service to listen for the device ready event and remove the status bar:
angular.module('myApp', ['ionic'])
.controller('MyCtrl', function($scope, Platform) {
Platform.ready(function() {
// hide the status bar using the StatusBar plugin
StatusBar.hide();
});
});
I used it to remove the status bar from the ios application with Ionic & Angular
FileName: config.xml
step1: add code in XML file
step2: import the plugin and implement it on your js file.
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="UIStatusBarHidden">
<true />
</edit-config>
<edit-config file="*-Info.plist" mode="merge"target="UIViewControllerBasedStatusBarAppearance">
<false />
</edit-config>
</platform>
for your .js/.ts file
Hiding and showing StatuBar
I used this plugin Link: https://github.com/apache/cordova-plugin-statusbar
import { StatusBar } from '#ionic-native/status-bar/ngx';
constructor(
private statusBar: StatusBar
){}
this.StatusBar.overlaysWebView(true);
this.StatusBar.hide();

Resources