Using Durandal with Phonegap/Cordova - ios

I'm trying to develop a Cordova/Phonegap application using Durandal for IOS (using a Mac), and am having some trouble getting started.
I've got Cordova loading with RequireJs and that's all working fine. This is what I've got in my main.js file:
define(function (require) {
var
cordova = require('cordova.ios'),
system = require('durandal/system'),
//app = require('durandal/app');
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
alert('Device is Ready!');
}
});
Notice I have app = require('durandal/app') commented out. If it IS commented out, then everything works fine. But as soon as I uncomment that, I don't get the alert anymore. I don't see anything out of the ordinary in the web inspector in Safari, and it seems like the app.js file gets loaded, but it stops everything else from happening there.
I know the docs say that you can use the optimizer, but is there no way to do the actual development in XCode and test without running the optimizer?
Thanks in advance for any help or ideas.

I believe there is an app variable in cordova, probably due to naming conflict. I created a sample and it worked with durandal. Please let me know if it doesnot work, i will post sample in github

Related

Cordova keyboard plugin issues with screen resizing and focusing

I'm building a mobile application for iOS using Meteor and Cordova. I'm having trouble configuring the screen correctly when an input field is clicked on to enter information. The screen does not focus in on the input field until after something is typed on the keyboard, similar to this video: https://github.com/cjpearson/cordova-plugin-keyboard/issues/62
However, in addition to this issue, clicking in the input field renders the constraints all out of whack. (Closing the keyboard makes everything fine again)
Currently I am using cordova-plugin-keyboard. I have unsuccessfully tried cordova-plugin-ionic-keyboard and ionic-plugins-keyboard. In addition to the plugin I'm using, I also have these lines of code, in accordance with this suggestion:
document.addEventListener('deviceready', function() {
Keyboard.shrinkView(true)
window.addEventListener('keyboardDidShow', function () {
document.activeElement.scrollIntoView()
})
})
Any help at all would be greatly appreciated! This issue has been plaguing me for quite a while.
You may try the following - this worked for me.
run meteor add cordova:cordova-plugin-keyboard#1.2.0 command
check cordova-plugins containing this cordova-plugin-keyboard#1.2.0
include App.setPreference('KeyboardShrinksView', true); in Mobile-config
run meteor reset
run meteor run ios-device --port 4000 --verbose
check config.xml containing this
< preference name="KeyboardShrinksView" value="true"/>
Do not manually edit the /.meteor/local/cordova-build/config.xml file,
as it will be regenerated at every meteor run ios/android or meteor
build, hence you will lose all your modifications.
https://riptutorial.com/meteor/example/16152/configure-your-cordova-project--config-xml-
https://docs.meteor.com/api/mobile-config.html
let me know if this is working on your side too.

Unity3D - Parse Migration

I have a Unity3D game currently hosted on parse. I am in the process of migrating it to mongoDB and Heroku. I have followed this link Parse Migration
Although its for iOS and I have tested it working on iOS, I am doing the same steps in Unity.
The code I am using in Unity3D is:
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
Server = "",
WindowsKey = ""
});
But nothing happens. If I initialize it like this on iOS, it works perfectly. But its not working on Unity. Any help would be greatly appreciated. Thank you
A while back when I was still using Parse I was using the ParseInitializeBehaviour.cs script attached in an object that persisted across scene changes.
The reason is that it does an additional call at the bottom apart from the ParseClient.Initialize() call.
I cannot find that script any more at current master though.

React-Native ios App crashes without report

I'm building an iOS app using React Native and trying to get it testable on phones.
If I plug my phone into the computer and "build" directly to the phone, the app is built correctly and opens/operates correctly, no problem.
But if I try to archive it and send it to phones using iTunes Connect's TestFlight or Fabric with Crashlytics, the app crashes immediately upon opening. It briefly shows the launch screen, but no more.
Moreover, there are no crash reports -- in TestFlight, in Crashlytics, or in XCode, once I plug the phone back in. So I'm operating in the dark here, without any information on what's breaking. Haven't been able to find a similar issue online, so I figured I'd just ask. Any ideas what could be going wrong?
Please let me know if there's any code or other data you might need to see. Some of it's confidential, but I'll try to post an approximate version.
As Chris Geirman suggested, the problem was a JavaScript error. I'm not sure people with similar problems will find this thread, but in case they do, here is the weird error that was occurring.
I had created a simple ORM system, with a BaseModel and a bunch of models that inherited from it. The BaseModel constructor looked like this:
constructor(props = {}, relations = {}) {
Object.keys(props).forEach((k) => {
// Save props to object
this[k] = props[k];
});
this.relations = relations;
this.className = this.constructor.name;
}
That last line was the problem. On my local simulator and if I build the app to my phone by plugging it in, this works fine. As in, if a Message model inherits from BaseModel, calling var msg = new Message(data, relations); msg.className returns Message.
But something about bundling/archiving/sending the app through TestFlight or Fabric.io minifies and uglifies the JavaScript, such that the class names are changed. So instead, if I do this -- var msg = new Message(data, relations); msg.className -- I'll get back a random variable name, something like 't'.
This was a problem in my app, because my home page contained a switch statement that worked off of the className:
iconContent() {
return {
Message: {
icon: <Image style={styles.feedItemIconImage} source={ require('../assets/img/icon_message.png') } />,
color: c.grass
}, ...
}[this.props.className] // from the model item
}
But 'Message' wasn't, as expected, the value of this.props.className -- 't' was. And so, if I were to try to tunnel into, say, the color value, I'd hit an error, because I was trying to access the color property of null.
Why that didn't report, I don't know (I followed Chris's suggestions and installed Sentry, but it still seemed not to report that error).
But that's what was going on. Minification/uglification occurred only when I installed the app on a phone via TestFlight/Fabric, and that's why the app only crashed in those conditions.
Hope this saves anyone running into a similar bug from tearing out their hair.
I'd like to share my own experience of production stage crash, whereas everything worked fine in development stage.
I had the similar problem which caused by the Reactotron logger. Since I'm not bundling it in production stage, a single line of console.tron.log crashed my app with full stealth. (Its kinda my fault, since I didn't give a damn about my linter with 'no-console' setting)
Here's the code snippet I introduce in my root level file, root.js.
if (__DEV__) {
...
console.tron = Reactotron;
...
}
Hope somebody finds this before wasting time figuring out what's wrong.
Not sure if you still have this problem - but if you do, I'd recommend checking out Bugsnag for react native error reporting - which reports crashes in both the JavaScript layer as well as the native layers (java/cocoa).
One of the harder problems to solve in react native crash reporting (as Sasha mentioned) is restoring the original stack traces when using minification and/or obfuscation - this is handled in Bugsnag by providing full support for JS source maps, as well as iOS symbolication and Android Proguard support at the native layers.
Let me know if this helps - I'm a founder # Bugsnag

Cordova resolveLocalFileSystemURL success call back failing on iOS

I've just created a new project and installed the file and file-transfer api's via CLI. I have already created a working app previously so I know how to use phonegap and have been doing so for a few years now.
Here is the code:
window.resolveLocalFileSystemURL("file:///localhost/var/mobile/Applications/96B4705C-C70D-4340-9A42-HJ1F28355D43/tmp/cdv_photo_015.jpg", function(fileEntry){
console.log(fileEntry.name);
}, function(error){
console.log('about to resolve this files errors');
console.log(error.code);
});
Nothing ever gets outputted in the console debugging window ...and yes I have debug installed cause I have console.log() in other parts of my code that show up.
It seems like there is an issue when passing URL data from navigator.camera.getPicture() to the file API when using window.resolveLocalFileSystemURL()...any ideas anyone. I'm up to date on phonegap api and everything and I have this issue for the past few days now...I can't seem to solve it.
***EDIT***
Seems like when you use Camera.DestinationType.FILE_URI as a parameter for navigator.camera.getPicture(). When you choose a picture and the success call back for navigator.camera.getPicture() is triggered, trying to window.resolveLocalFileSystemURL from the URL that getPicture returns just fails. But if you set Camera.DestinationType.NATIVE_URI it at least returns something but it's in a format that can't be used with the file-transfer api exp: assets-library://asset/asset.JPG?id=220BCEAE-F1EA-4A6A-83B2-AB8833A90BF2&ext=JPG
Seems like this was a bug in the file api v1.0.0
https://issues.apache.org/jira/browse/CB-6116
Temp solution is there as well.
Seems like "/local/" was causing the issue. Remove it from incoming uri's if it exist and the resolve should work.

Phonegap application would not work in iOS

I have a very interesting problem. I have a phone-gap application that I am building. It works fine when we run it in the android environment, or even when we open index.html in firefox. But when I try to run this on an iPad simulator in Xcode, it fails.
The application installs fine and displays the start up page correctly. The next thing my application requires is to open a job attached in the email. But as soon as we do that, thats when it starts failing. It does not display the body text. The header and the footer are displayed fine.
To me this does not look like any javascript error because I am able to run this code on other platforms. I think its got to do with some css I am using which might not be compatible with iOS. Also, I have this other problem that my code will not run on any version except phone gap-1.3.0. I am not sure if that has anything to do with this too.
Anyways, I would like to know your thoughts on this.
ok the offending code was found to be the following:
$.mobile.touchOverflowEnabled = true;
I just stumbled across this and I am not sure why its breaking my app. Anybody got any ideas.
After commenting this code out, my app worked fine.

Resources