Geolocation not working on iOS with Meteor - javascript

It's been 5 hours i'm struggling with Meteor.
I want to get Geolocation.latLng(). It works perfectly on my browser, I coupled it with GoogleMaps to put a marker on a map. I'm following this example and didn't touch it much.
When I compile on iOS the Geolocation returns weird errors on my simulator (iPhone 6 / iOS 8.3) such as Geolocation failed : Position retrieval timed out, sometimes it's another one which's very similar (note : it asks me if i want to share my location when i launch the app, and i accept)
Sometimes it says it just compiled and I get an old version of my app too.
What's happening ? Is it me or it's really THAT buggy once you try to make a real world project ?
This to-do list tutorial looked very magic but once you understood how it works and you try something real, it's kind of disappointing ... Sounds very unstable and not ready.
Don't hesitate to tell me if i'm doing something wrong ;)
UPDATE : i've searched a lot more and i'm now trying to setup differently the timeout limit of the geolocation package to avoid this error.
Sadly, i realized timeout : Infinity is the default value of the source : sounds like an issue.
Nothing is working so far. If anyone has an idea, let me know on that too ...

I finally made it work. First I realized you have to setup the accessRule thank to Lucas's answer but it wasn't enough.
// In a mobile-config.js in the project
App.accessRule('*://maps.googleapis.com/*');
The iOS Simulator provided by Apple seems to have bugs : the position isn't retrieved correctly, or not at all. It's only working if i set the the Debug > Location to City Ride ; even Apple wasn't working properly on my hand.
If nothing works for you, just try all the possible Location, it might be the problem.

Have you define an accessRule in your mobile-config.js? If not, try this.
App.accessRule('*://maps.googleapis.com/*');

Here, clone this sample app I put together a while back:
https://github.com/ffxsam/whats-nearby
It works on desktop as well as mobile. All you have to do is add a settings.json and add your Google Places API key in there.
{
"apiKey": "...."
}

Related

how do you allow javascript communications with Flex/Flash/Actionscript

Well here's a problem.
I've got a website with large javascript backend. This backend talks to a server over a socket with a socket bridge using http://blog.deconcept.com/swfobject/
The socket "bridge" is a Flex/Flash .swf application/executable/plugin/thing for which the source is missing.
I've got to change it.
More facts:
file appExePluginThing.swf
appExePluginThing.swf Macromedia Flash data (compressed), version 9
I've used https://www.free-decompiler.com/flash/ to decompile the .swf file and I think I've sorted out what's the original code vs the libraries and things Flash/Flex built into it.
I've used FDT (the free version) to rebuild the decompiled code into MYappExePluginThing.swf so I can run it with the javascript code and see what happens.
I'm here because what happens isn't good. Basically, my javascript code (MYjavascript.js) gets to the point where it does
window.log("init()");
var so = new SWFObject("flash/MYappExePluginThing.swf"", socketObjectId, "0", "0", "9", "#FFFFFF");
window.log("init() created MYappExecPluginThing!!!");
so.addParam("allowScriptAccess", "always");
log("init() added Param!!");
so.write(elId);
log("init() wrote!");
IE9's console (yeah, you read that right) shows
init()
created MYappExecPluginThing!!!
init() added Param!!
init() wrote!
but none of the debugging i've got in MYappExePluginThing.as displays and nothing else happens.
I'm trying to figure out what I've screwed up/what's going on? Is MYappExePluginThing.as running? Is it waiting on something? Did it fail? Why aren't the log messages in MYappExePluginThing.as showing up?
The first most obvious thing is I'm using FDT which, I suspect, was not used to build the original. Is there some kind of magic "build javascript accessible swf thing" in FlashBuilder or some other IDE?
First noteworthy thing I find is:
file MYappExePluginThing.swf
MYappExePluginThing.swf Macromedia Flash data (compressed), version 14
I'm using Flex 4.6 which, for all I know, may have a completely different mechanism for allowing javascript communication than was used in appExePluginThing.swf
Does anyone know if that's true?
For example, when FDT runs this thing (I can compile but FDT does not create a .swf unless i run it) I get a warning in the following method:
private function init() : void
{
Log.log("console.log", "MYappExePluginThing init()");
//var initCallback:String = Application.application.parameters.initCallback?Application.application.parameters.initCallback:"MYjavascript.MYappExePluginThing_init";
var initCallback:String = FlexGlobals.topLevelApplication.parameters.initCallback?FlexGlobals.topLevelApplication.parameters.initCallback:"MYjavascript.MYappExePluginThing_init";
try
{
ExternalInterface.addCallback("method1Callback",method1);
ExternalInterface.addCallback("method2Callback",method2);
ExternalInterface.call(initCallback);
}
catch(err:Error)
{
Log.log("console.log", "MYappExePluginThing init() ERROR err="+err);
}
}
I got a warning that Application.application was deprecated and I should change:
var initCallback:String = Application.application.parameters.initCallback?Application.application.parameters.initCallback:"MYjavascript.MYappExePluginThing_init";
to:
var initCallback:String = FlexGlobals.topLevelApplication.parameters.initCallback?FlexGlobals.topLevelApplication.parameters.initCallback:"MYjavascript.MYappExePluginThing_init";
which I did but which had no effect on making the thing work.
(FYI Log.log() is something I added:
public class Log{
public static function log(dest:String, mssg:String):void{
if(ExternalInterface.available){
try{
ExternalInterface.call(dest, mssg);
}
catch(se:SecurityError){
}
catch(e:Error){
}
}
trace(mssg);
}
}
)
Additionally, in MYjavascript.js MYappExePluginThing_init looks like this:
this.MYappExePluginThing_init = function () {
log("MYjavascript.js - MYappExePluginThing_init:");
};
Its supposed to be executed when MYappExePluginThing finishes initializing itself.
Except its not. The message is NOT displaying on the console.
Unfortunately, I cannot find any references explaining how you allow javascript communication in Flex 4.6 so I can check if I've got this structured correctly.
Is it a built in kind of thing all Flex/Flash apps can do? Is my swf getting accessed? Is it having some kind of error? Is it unable to communicate back to my javascript?
Does anyone have any links to references?
If this was YOUR problem, what would you do next?
(Not a full solution but I ran out of room in the comment section.)
To answer your basic question, there's nothing special you should need to do to allow AS3-to-JS communication beyond what you've shown. However, you may have sandbox security issues on localhost; to avoid problems, set your SWFs as local-trusted (right-click Flash Player > Global Settings > Advanced > Trusted Location Settings). I'm guessing this not your problem, though, because you'd normally get a sandbox violation error.
More likely IMO is that something is broken due to decompilation and recompilation. SWFs aren't meant to do that, it's basically a hack made mostly possible due to SWF being an open format.
What I suggest is that you debug your running SWF. Using break-points and stepping through the code you should be able to narrow down where things are going wrong. You can also more easily see any errors your SWF is throwing.
Not really an answer, but an idea to get you started is to start logging everything on the Flash side to see where the breakage is.
Since you're using IE, I recommend getting the Debug flash player, installing it, then running Vizzy along side to show your traces.
Should give you a good idea of where the app is breaking down.
Vizzy
Debug Player

How to load Component and its Classes in my website

I am trying to over ride one the notification popups of browser using the following code:
var branch = Components.classes["#mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
But in Mozilla Firefox, I get the error Component.classes is undefined.
And in Chrome Browser, I get the error Component is undefined.
Well I have realised I need to include something in my website. But I am unable to find exactly what is required.
Please anybody help. I googled about it a lot, but I have never used this thing before(the Classes) and I am unable to search what will help me out. i dont even have any idea that what will be the tags for this thing. I have never used Component or its classes
My website is in ZF2.
Components Object is non-standard feature. See https://developer.mozilla.org/en/docs/Components_object.
It also says
Warning: This object is only intended for code running with chrome
privileges. Exposing the object to regular web code was a mistake.

is there anything like robotium's solo.clickOnText in MonkeyTalk?

does anyone know if there is a similar command to robotium's
solo.clickOnText within MonkeyTalk?
or how to do the same with javascript?
thanks for your help.
Update:
I have found in monkeyTalk syntax - to tap on any component labeled "ok"
View OK Tap
but for some reason the script says it has run ok, but nothing happens on the app.
When I record the action with the recorder it uses the
Table ITEM selectIndex 1
with the same result.
This is a native Android app and the solo.clickOnText command works well with Robotium, but we were wanting to try MonkeyTalk as it is quicker to record.
Robotium now also supports recording http://robotium.com/

is there a difference between alert() vs notification.alert() using phonegap in xcode?

I'm trying to figure out how to fix the titles on my messages that pop up in my iOS app I am attempting to work on seeing as the messages tend to pop up with a long path of where the file is, then the message which is to a point counter productive for the needs of the popup. That said. I started searching for how to fix it and I came up with the notification.alert(). I am assuming that the standard alert() I am using is binded to that with the way cordova/phonegap works. But does this mean I should instead of alert('message') use notification.alert() if so. Then how can I fix the one that is auto generated by the app when I am looking for geolocation information?
As requested "What am I using for geolocation"
geocoder = new google.maps.Geocoder();
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
}
Which is what I do in my web based apps. I know this may not be the ideal solution for phonegap/cordova specifically. So I am searching for the right answer to this as well. But mostly the alerts. I am currently porting over an existing web based app to a phonegap version for iOS so the original question is should I remain using alert() where I do in my web based version or should I convert those as well to notification.alert() or does it really make that big a difference.
Like Noogen already mentioned, you should use notification.alert if you want it to look native and you want to customize the title etc.
For iOS 6 and above, to change the alert asking for permission to use current location, you can set the value for key NSLocationUsageDescription (or Privacy - Location Usage Description) in your app's Info.plist. The title of the alert will still be "YourAppBundleName" Would Like to Use Your Current Location. The value of the NSLocationUsageDescription will be shown as an explanation below the title.
There are similar properties for other permission dialogs as described in Apple's Information Property List Key Reference.
What Google geolocation code are you using that is doing the alert? API should not be doing any alert. The alert and notification.alert are two different functions.
Default alert webview/browser display the page URL in the title. Phonegap people did a great thing by providing the additional notification (alert, prompt, and confirm) API. This is a feature/benefit of PhoneGap. It is also required if you don't want to be rejected by Apple with app must be native look and feel clause. Just change all your alert to notification.alert.
You can also hack/override default alert with window.alert = notification.alert, but I do not recommend this.
Alternatively, you can do something like my AngularJS phonegap $notification friendly factory shown in my response here: Angularjs + phonegap logout on history back

jQuery.data() works in Mac OS WebKit, but not on iPhone OS?

I'm playing around with jQTouch for an iPhone OS app that I've been toying with off and on for a while. I wanted to try my hand building it as a web app so I started playing with jQTouch. For reference, here is the page+source (all my code is currently in index.html so you can just "View Source" to see it all):
http://rpj.me/doughapp.com/wd/
Essentially, I'm trying to save pertinent JSON objects retrieved from Google Local into DOM objects using the data() method (in this example, obj is the Google Local object):
$('#locPane').data('selected', obj);
then later (in a different "pane"), retrieving that object to be used:
$('#locPane').bind('pageAnimationEnd', function(e, inf) {
var selobj = $(this).data('selected');
// use 'selobj' here ...
}
In Chromium and Safari on the desktop OS (Snow Leopard in my case), this works perfectly (try it out).
However, the same code returns undefined for the call to $(this).data('selected') in the second snippet above. I've also tried $('#' + e.target.id).data('selected') and even the naive $('#locPane').data('selected'). All variants return undefined in the iPhone OS version of WebKit, but not on the desktop.
Interestingly, the running this on Mobile Safari in the iPhone Simulator fails as well.
If you look at the full source, you'll see that I even try to save this object into my global jQTouch object (named jqt in my code). This, too, fails on the mobile platform.
Has anyone else ever ran into this? I'll admit to not being a web/javascript programmer by trade, so if I'm making an idiot's error please call me out on it.
Thank you in advance for the help!
-RPJ
Update: I didn't make it clear in the original post, but I'm open to any workaround if it works consistently. Since I'm having trouble storing these objects in general, anything that allows me to keep them around is good enough for now. Thanks!
Have you tried using HTML5 data-ref attributes? The data has to be stringified, but you can just do
$('#locPane').attr('data-selected', "somestring");
and still have valid HTML5 markup.
As far as I can tell there seems to be a bug in Mobile Safari storing objects like this. So what I did was to simply store the components of the object in the documents data store.
$(document).data( "lessonCode" , lesson.lessonCode);
$(document).data( "question" , lesson.question);
$(document).data( "answer" , lesson.answer);

Categories