I have a backbone app running with require and cordova. It runs perfectly in the browser and when emulating through xcode on all devices. But for whatever reason when I attempt to run it through the device (iphone 5) it starts up but never runs, instead only giving me a blank white screen. I have attempted to console log using cordova's console logging plugin which allows for console logs to be written to xcode's terminal, but it's consistency is shotty at best and i haven't gotten anything legitimate that could lead to a reason it runs on one but not the other.
Has anyone ever dealt with this? I know this is a very vague question, just trying to see if anyone has ever ran into the same issue more or less.
Here is the body of my index.html file...
<body>
<div id="container">loading...</div>
<script type="text/javascript" src="cordova.js"></script>
<script data-main="js/main" src="js/libs/require.js"></script>
</body>
Then this hits my main file, I am changing background color as a way of debugging, I am unable to change the background color from this file but I am able to in app.js ...
require.config({
baseUrl: "js/",
paths: {
jquery: 'libs/jquery/jquery-1.8.2',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-1.0.0-min',
text: 'libs/require/text',
templates: '../templates',
router: 'router',
app: 'app',
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
}
}
});
require(['app', 'router', 'models/SessionModel'], function(app, AppRouter, SessionModel) {
$('body').css('background-color', 'yellow');
document.addEventListener("deviceready", run, false);
function run() {
app.router = new AppRouter();
app.session = new SessionModel({});
app.session.checkAuth({
// Start the backbone routing once we have captured a user's auth status
complete: function(){
Backbone.history.start();
}
});
}
});
Then here is the very basic app file...
define([
"jquery",
"underscore",
"backbone"
],
function($, _, Backbone) {
var app = {
};
return app;
});
I guess you are getting an error even before the Cordova console plugin is loaded.
Try the following: Paste an alert message before the deviceReady event is fired.
Start the App, attach the Safari remote debugger and dispose the alert message, now you can see all the console output from there on. Most likely you will find a requirejs or cordova error there.
Related
I am using the new webcomponent <pwa-install >Install </pwa-install> to install my PWA app build using PWA Builder. The button works well but the only problem I have is that I cant make it to disappear if the app has already been installed.
I have tried to hide the install button and only show it when the beforeinstallprompt is activate but I failed with that:
self.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
this.deferredPrompt = e;
$("#installbanner").show();
});
I also tried the appinstalled method, that did not work as well.
self.addEventListener('appinstalled', (evt) => {
app.logEvent("App is installed");
$("#installbanner").show();
});
I also tried displaying all the available methods that are contained within the <pwa-install >Install </pwa-install> but it just showed jibrish.
I am really sorry to bug everyone, may you please kindly assist
you can try using media display query, for example you can try one of the following properties:
#media all and (display-mode: standalone) {
pwa-install{
display: none;
opacity: 0;
visibility: hidden;
}
}
I am working on progressive web app with ionic 3 and angular 6 framework.
Every thing works fine but when I press my browser back button or mobile back button my application get closed.
I tried to search how to do this, I am able to disable browser back button with java script but on mobile app it's not working.
<script>
// window.onbeforeunload = function() { return "Your work will be lost.";
};
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
}, 100);
</script>
I tried to register the back button event and lot's more but none of that is worked fine for me.
Can anyone have same issue then please tell me how to resolve this.
Thanks,
Dattatray
You can use Ionic's Platform to override the physical back button on Android.
Add it into app.component.ts file as such :
import { Platform } from 'ionic-angular';
constructor(public plt: Platform) {}
platform.registerBackButtonAction(() => {
//Add your code here
},100);
Ionic Platform Service.
I was making a native app in iPhone4 with iOS 4.3
in my Body onLoad i m adding
document.addEventListener("pause", Game.prototype.pauseListener.bind(this), false);
document.addEventListener("resume", Game.prototype.resumeListener.bind(this), false);
and in that same file i m writing a function
Game.prototype.resumeListener= function()
{
console.log("in resumeListener");
this.PauseGame(false);
}
Game.prototype.pauseListener= function()
{
this.PauseGame(true);
}
this code is working perfectly fine in Android and when i manually minimise the app, but when the application is interrupted by a voice incoming call the application dont pause.
Basically Pause and Resume event are not fired.
I m using Phonegap1.4.1
I believe your event listeners are not being established because you are using Object.bind() on the handler functions, and .bind() is not available in the iOS WebKit widget. (This is surpising because .bind() is available in the desktop WebKit (Chrome and Safari) versions.)
The easy solution is to add a polyfill definition for Object.bind(). I use the one from the MDN bind documentation page, and haven't had any problems with it.
sorry but i cant make a comment yet ;)
have you checked the two other events (active and resign only for ios)? more information: http://shazronatadobe.wordpress.com/2012/03/14/apache-cordova-lifecycle-events-in-ios-4-versus-ios-5/
or see iOS Quirks in the documentation: http://docs.phonegap.com/en/1.6.1/cordova_events_events.md.html#pause
You need to add your listeners in the deviceready instead of in the onLoad.
Just like here for example
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
document.addEventListener("pause", onPause, false);
}
function onPause() {
}
Hope it helps :)
I've started developing for iPhone using PhoneGap and an iPhone running iOS 5. With the following code, the deviceready and online events appear to fire when the application starts but none of the others, in particular, the resume / pause events appear to. I've tried using the menu button to close the app and then re-open it but nothing appears to fire the resume event.
If anyone could shed any light on this it would be much appreciated.
Thanks in advance!
window.addEventListener('load', function () {
document.addEventListener('deviceready', onDeviceReady, false);
}, false);
function onDeviceReady() {
document.addEventListener('resume', onResume, false);
document.addEventListener('pause', onPause, false);
document.addEventListener('online', onOnline, false);
document.addEventListener('offline', onOffline, false);
}
function onResume() {
alert('resume');
}
function onPause() {
alert('pause');
}
function onOnline() {
alert('online');
}
function onOffline() {
alert('offline');
}
For me this was an ID10-T error: my PhoneGap app was redirecting to a URL which I had changed in one place but not in the other. The result was it looked like I was running my development code but I was actually running against a remote server running code without onResume and onPause events!
BTW, documentation for these events can be found at http://docs.phonegap.com/en/1.4.1/phonegap_events_events.md.html
See this Page Tab (its only a test page, just fan it :-)
http://www.facebook.com/pages/Ludwig-Test/127771653944246?sk=app_165323306883725
its working in FF. But not in IE.
You should see 2 Alert boxes, one from fbAsyncInit and one from getLoginStatus. in IE neither ist coming. but now to the funny part. Press F12 to open the DeveloperTools from IE. and click on "iPad Gewinnspiel" again. now its working.
Right klick on the icon of "iPad Gewinnspiel" to open the page in a new tab. -> not working. again with F12 and it will work.
Does anyone have any idea what i could do to fix this ?
TIA
You need to initialise the FB object inside the async function
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_ID',
status : true,
cookie : true,
xfbml : true,
oauth: true
});
// Do stuff with FB object here
}
I should really not use console.log in the code when i want to test IE.....
as soon as this for IE unknown commands are out of the code is working as expected.
Funny enough when the developer console is open this function exists and are working. stupid IE developer who thought of such nonsense.
see What happened to console.log in IE8? for more information.