Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 1    Views: 72

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
02/29/16 08:40 AM (8 years ago)

Lat Lon Merge fields Fix ios Latitude Longitude

I came across a problem today when trying to use merge fields to pass latitude and longitude to an externally hosted html file. My app uses a custom url plugin and the url I am using is structured in the control panel as follows: http://mybtserver.co.uk/testpage.html?lat=[deviceLatitude]&Lon=[deviceLongitude] The problem is that what gets passed is not lat and lon of where I am (UK), it is somewhere in Gabon. I read that merge fields may be broken and I tried the fixes in the posts here: https://www.buzztouch.com/forum/thread.php?tid=141D373F5D9B1417555AC5D and https://www.buzztouch.com/forum/thread.php?tid=DA308929DBC29D1DB83B7A8 The solution is there, but as we are now on IOS 9.x and a few other things have since changed, I thought I'd post this update with easy to find keywords in the subject. Credit to Chris1 for his original hard work. I believe that to fix, you need to put the code in the plugin using the merge fields - in my case, the custom url plugin. In Xcode, search in the plugin.m file for //appDelegate BT_appDelegate *appDelegate = (BT_appDelegate *)[[UIApplication sharedApplication] delegate]; Following Chris1's suggestion, I added the following line immediatly afterwards: if ([appDelegate.rootLocationMonitor.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) [appDelegate.rootLocationMonitor.locationManager requestAlwaysAuthorization]; I believe the BT_info.plist now holds the appropriate information already, I did not need to change that. Now if I launch the app for the first time, I am prompted to allow location usage and the correct device values for lat & lon are used. Enjoy!
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/29/16 09:18 PM (8 years ago)
Thanks for the props Alan - glad you got it working! :)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.