Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 34    Views: 108

SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
02/01/14 05:25 PM (11 years ago)

Smug Msg Loc 'Quick Fix' (Maybe)

It seems to work in the simulator, I hope it works elsewhere. Apologies for not getting to this sooner or more thoroughly; I got bills to pay, and calls to return. Time is always at a premium. Be that as it may, place these lines of code in the "sw_smugmsgloc.m" file around line 376, in the 'viewDidLoad' method, AFTER '[super viewDidLoad];' <replaceYourAppName>_appDelegate *appDelegate = (<replaceYourAppName>_appDelegate *)[[UIApplication sharedApplication] delegate]; smugLat = appDelegate.rootDevice.deviceLatitude; smugLng = appDelegate.rootDevice.deviceLongitude; if (smugLat.length < 1) smugLat = 0; if (smugLng.length < 1) smugLng = 0; That 'should' clean things up a bit. Let me know. Cheers! -- Smug Edit: what seems to be an issue in iOS7 (and why it didn't appear in iOS6 I'll never know) with the speed of updates. It seems that the device may or may not update it's location 'fast enough'. So, in the above code, it assigns the value of the device lat/lng immediately, and if there isn't a value, it assigns it a value of "0". If both Lat and Lng are not immediately available, it will assign the coordinates '0,0' (a few hundred miles south of Nigeria) to the device until it updates. If you want your location to be there instead of Africa, change '0' to 'your coordinates'. for example 13.5 instead of 0 for Lat, and 144.8 instead of 0 for Lng. It will eventually correct itself, but it still wants coordinates at the beginning, even if they're just '0'.
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
02/01/14 05:29 PM (11 years ago)
So this would be a fix for the 'JSON couldn't save' error?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/01/14 06:15 PM (11 years ago)
No. That would most likely be your BT Control Panel. The only fix I know of at the moment is to change your nickname to something else and try again. Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/01/14 09:34 PM (11 years ago)
This was for the Send Email issue. Added the code above- it only fixes simulator in case of no location. If you use Debug-Location-Apple in Simulator, error still there. However on iPhone, it works for the first time pressing email button and then the Send Email. After that, every time the Email button is pressed it flips back to SMS being highlighted. The issue seems to be with logic after line 345 where after email button is pressed send button acts based upon which of the buttons below are selected. Always falls into line 364 for SMS no matter Will try debugging code tomorrow. =========== One idea to simplify would be to eliminate the "Send Email-SMS" button, and just have the SMS and eMail buttons activate the send. One-click ;)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/01/14 10:00 PM (11 years ago)
@NCBuzz That's actually what I was planning to do; get rid of the segmented button. It doesn't look cool in iOS7 anymore anyway (of course, nothing looks cool in iOS7, imho lol!) I'll try and get to it before the next couple of days is out. Cheers! -- Smug
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/02/14 02:55 AM (11 years ago)
No need to apologize, Smug, take your time! The fix didn't change anything for me (tested on iPhone 5, iOS 7, deployment targets 6.0 and 7.0). BTW, there's another thing you could polish. You get a global view of where you are, but you can't really zoom to see exactly where you are (i.e. street level). With deployment target 6.0 you can zoom a little, but at some zoom level (far from street level) the map jumps back to global view. With deployment target 7.0 you can't zoom at all anymore. Cheers Jack
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/02/14 03:20 AM (11 years ago)
Yeah, that was mentioned to me. The view as it is right now uses 'apple' views, rather than 'google' views. This is why I use the 'hybrid' display; if you don't have an accurate map (like Guam) then the 'Hybrid' view will at least show the satellite image. But back to 'zoom'. Apples maps have some freaky kind of 'region' designation that isn't like Googles "zoom to level 12" sort of thing. And since it was intended as more of a 'rescue' sort of function, I didn't give it too much thought. Remember, this was in my iOS infancy, and it ended up being the kind of code where my mindset was 'ok I finally got it to work now… so don't *touch* it', lol! But for my "Enhanced" Message Loc (unreleased, and probably will remain so) I found a nifty class that would allow zooming in and out of Apple Maps, making that functionality a LOT easier. I may throw that in there for the next release, if not the next update… Believe me, you'll get your moneys worth ;) Cheers! -- Smug
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/02/14 05:33 AM (11 years ago)
LOL - As a member, I can even afford to pay twice the price :-) Cheers Jack
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/02/14 06:53 AM (11 years ago)
I've gone ahead and released an update. This will cure most 'iOS 7' issues. It will do nothing for BT Hosted Control Panel problems, sadly. It also adds Zoom capability, although the map still wants to zoom to the user location. Separate buttons for SMS and Email should alleviate that pesky acting segmented control. Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/02/14 07:46 AM (11 years ago)
Awesome update Smug- Thanks! The good fix news: (iPhone 5, iOS7) * Separate Email and SMS buttons work great. * Zoom controls all work perfect.- a big improvement :) Two new issues: 1) When map first displays you are always looking at the Gulf of Guinea ;) -(lines 68-69 in smugmsgloc.m sets smugLat=13.5 and Lng=144.8 initially as default values. Note: The correct lat and long are displayed below the map, as well as included in the SMS and email. Scrolling and zooming map over to US shows current device location. 2) Top Nav bar is missing. Appears solid white with no Bar Title or Back. ------ Will wait to see if Chris has any ideas on the Control Panel
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/02/14 07:50 AM (11 years ago)
Odd… I'll fix it early tomorrow if that's ok; It's about 1am here; well past my bedtime. I probably mucked it up working out the old 'region' method and putting in the new zoom class. Not a biggie, but I tend to mess things up when I code while sleepy. Cheers! -- Smug
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/02/14 07:50 AM (11 years ago)
Good Lord, I'm currently drowning south of Ghana and I'm not a good swimmer, what should I do? ... much better now, zoom capability ok but navigation bar not displayed, showing lat long ok (with good precision) but not the user location on map (see above), SMS and e-mail not functional (but this is a BT3.0 core bug, right?)... Cheers Jack
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/02/14 07:52 AM (11 years ago)
Sweet dreams, Smug!
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/02/14 07:53 AM (11 years ago)
Go to sleep Smug - many thanks
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/03/14 12:26 AM (11 years ago)
Ship ahoy! Captain Smug's rescue ship in sight! But I want to go home, even if Guam looks nice from the Space Station! ;-)
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/03/14 12:36 PM (11 years ago)
Saw that there is now a v1.7 from Smug that addresses the initial map display location. ( no more swimming ;) Won't be home until late tonight- has v1.7.also addressed the Nav Bar display? Smug- whenever you get a chance would you add the date by the v1.7 in the BT market. Thanks again for all of your help.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/03/14 03:10 PM (11 years ago)
Nav Bar display was an oopsie; it was rectified. I don't know what 'Add the date by the v1.7 in the BT market' means. Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/03/14 05:59 PM (11 years ago)
Smug, == Results of testing ============ Part of the challenge is testing in different parts of the world ;) Here is what I found tonight: 1) Nav Bar is fixed. 2a) Initial center location is hard coded by line 69-70 (rather than device). The problem with this is the map is initially displayed centered on that hard coded location. 2B) The Current Device Location visual round circle and bubble text is not shown until the map is scrolled or zoomed. Seems that this might me a limitation that others have had to deal with- like the Location map which initially displays a zoom level of US, and then performs an animated zoom to user location. Thanks PS: "Add the date in BT market" meant in your description where you list all of the versions and what was updated in the plugin, it would be helpful to list the date on the newest one so people would know when it was updated. (Only way to tell until BT market is updated.)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/03/14 10:27 PM (11 years ago)
1) yeah, that was my bad. It was a silly error. 2A) Only if the Device doesn't have "last known coordinates". But just in case, I changed a little. Should be mo better. 2B) (or not 2B) That's 'supposed' to be controlled by the Map Property: [smugView setShowsUserLocation:YES]; Which is already set. So I'm not sure what to say at the moment. I did fiddle around with a couple of things, so if it persists, let me know, but I'm not sure what I can do about it 'directly'; it's an intrinsic property. Either it's on, or it's off. And I have it 'on'. --- I've already worked out a way to have the map Start above your region; it's just a matter of placing the center over your area (via coordinates) before showing the map. I've already modified mine. I don't modify the plugin, because your location is different than mine. However, if this is something you'd be interested in, place the 'soon to be mentioned' code in the 'viewDidLoad' around line 76 or 77 BEFORE this line: [self performSelector:(@selector(displayMap)) withObject:nil afterDelay:0.2]; The 'Soon To Be Mentioned' code that you would place AFTER the above line would be this: CLLocationCoordinate2D myFirstAppearance = CLLocationCoordinate2DMake(13.50000, 144.800000); [smugView setCenterCoordinate:myFirstAppearance zoomLevel:swZoomLevel animated:FALSE]; Naturally, you'll want to replace the values '13.500000' and '144.800000' with your own. 1) You're creating a Coordinate using a (double) value for both Latitude and Longitude. 2) You're setting the smugView (a MapView) center to those coordinates, along with a default zoom, and an animation. The 'zoom' is sort of important, because you don't want it loading at one zoom, then suddenly in another routine find a radically different zoom value. It looks funky. And the animation doesn't really matter, because 'at this time' the map isn't visible anyway, so animating it would just take unappreciated resources. This will setup the center location of the Map before it's drawn, so that when it appears, it will 'start off' over the center coordinates you've fed it. Make sense? :) On the date thing. There is a rather loose set of guidelines for building plugins. I think a stricter standard would probably be a good thing, but at the moment, considering the Buzztouch 'infrastructure' as a whole, there aren't enough bodies to do everything, so although I suspect it's on a 'to do' list somewhere, it might be a bit before it gets done. In the admin section of your BT self hosted server, there is an area where you can 'check for updated plugins' and it will let you know what has been updated in reference to the version number the developer posted on the plugin. That may be part of why it hasn't been done; perhaps they don't feel it's needed. However I like the idea… I'll start putting a 'last edited on XX/XX/XXXX' type of line at the top of my 'Read Me' files, and as usual, will detail the changes in the change log area, located further down the read me. But I can't vouch for everyone else. Cheers! -- Smug
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/04/14 01:10 AM (11 years ago)
Hi Smug, Almost 100% OK now! I just can't use the SMS and e-mail functions... a BT3.0 core-related bug? In a former post, NCbuzz said these functions are ok, but on my iPhone they are not! Cheers Jack
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/04/14 01:16 AM (11 years ago)
(you just forgot some smugplug_appdelegate here and there)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/04/14 04:08 AM (11 years ago)
I can't be 100% certain, but I'm 'leaning' towards it being a BT Core issue. Those reasons are: 1) It's easy. All I have to do is point my finger ;) 2) Using the same code, it works fine on my iOS 6 iPhone 4; both SMS and Email 3) Using the same code, it 'looks' like it should work, but it doesn't on my wife's iPad with iOS 7. I'll snoop around iOS 7 mail protocols and see if there is any radical change. There were a few deprecated calls that needed to be fixed, but I don't 'think' they should affect use. I'll double check just to be sure. Oh, and I fixed the "smugplug" (my test app) references, but updated the plugin without advancing the version; it's such a simple edit I didn't think it warranted it's own number. Cheers! -- Smug
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/04/14 05:36 AM (11 years ago)
Thanks a lot, Smug! I'm 99% certain it's a core issue... But maybe solved now, see this thread: https://www.buzztouch.com/forum/thread.php?tid=059ED7477E25DCD8F819F16 (and check the link to Jake's thread). Haven't tried yet! Cheers Jack
 
Annonymous
Profile
02/04/14 01:51 PM (11 years ago)
Just to repeat- I am running on iPhone5s IOS 7 SMS and eMail work fine on my phone since Smug 2/2/2014 version Tab/Non Tab layout has no effect on any of the behavior-so don't think this has anything to do with Jake thread. Note Smug's #3 from early this morning. I think he sees map centering ok on iOS 6 and not on iOS7 iPad. That is same behavior I see on my iPhone iOS7. - The code in thread above and listed below had no visible effect on IOS7: CLLocationCoordinate2D myFirstAppearance = CLLocationCoordinate2DMake(35.000000, -78.000000); [smugView setCenterCoordinate:myFirstAppearance zoomLevel:swZoomLevel animated:FALSE]; [self performSelector:(@selector(displayMap)) withObject:nil afterDelay:0.2]; ======= I started a different thread about dates of core updates as well. Because those of us who are BT hosted do not see dates...
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/06/14 07:24 PM (11 years ago)
The post above somehow was posted without my account info. (wish I could edit or delete it...) ================================ Good News: The Starting Map location display now works exactly as Smug has designed on my iPhone iOS7)! (I will explain what happened ;) The plugIn detail on BT market for Smug's Message Location clearly states "It is REQUIRED that you Enable GPS (Start Tracking Location:Turn on GPS) via the 'Core' page of your BT App control panel." I had followed directions in Core Properties and selected <No. Do not start GPS on Launch> (It's generally best to leave this setting OFF unless you're certain end-users are aware of the purpose of you tracking their devices location.) This had worked fine with the Location Map screens (I have 2 in my App). They prompt user "AppName" Would like to Use Your Current Location. After turning on in either Location Map screen, the other screen works fine. However the only way that Smug's MsgLoc currently works is if the App has the services set in Core Properties. ================= However - The issue is that if the Core is set to Yes, and the first time a user launches they select "Don't Allow" the MsgLoc will never work. In testing, it required the App to be removed from phone, re-installed and select YES.) Not sure why after turning on in one of the other screens, it doesn't then work in MsgLoc?? Smug- Can you add the same Alert when the Screen starts like the Location Map to fix this? (Wish I had caught this earlier to save you some time...)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/06/14 07:47 PM (11 years ago)
I can do that. It won't be immediately, I'll be under the gun for the next couple of days… but If I get a chance before that I'll spruce it up. That won't take too much. Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/06/14 07:51 PM (11 years ago)
Thanks. So cool now that it is working. As soon as BT sorts out the Control Panel issue we are golden :)
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/07/14 02:15 AM (11 years ago)
Yikes! I thought about the GPS location issue, but didn't say anything... Should have... Don't forget to use the Allow GPS plugin in your app, to give the user ability to switch to 'allow' if on first launch they decide to turn it off! In my apps, I always set to 'turn on GPS' on launch but I know many users say 'no' when they see the alert at first launch...
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/07/14 04:32 AM (11 years ago)
I never even thought about it. Everything I do is location based, so should a user opt *not* to turn on their GPS, they may as well leave my apps closed. That said, it makes perfect sense for almost any other situation but mine, lol! Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/22/14 08:08 AM (11 years ago)
doUpdate I had turned on the debugging statements while checking out slowness on another screen. Turns out that when I leave the smugmsgloc screen, the [self stopUpdating]; never happens. as a consequence, the code continues to check the gps location forever. - How do I force it to stop when exiting the screen. (i.e. Back Button, or TabBar button)? I was wondering why my iPhone battery was getting killed during testing ;)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/22/14 04:16 PM (11 years ago)
I'm not entirely sure about that… There is an iOS method called 'viewWillUnload' that is supposed to stop the updates… You might try to add this: -(void) viewWillDisappear:(BOOL)animated { [self stopUpdating]; } If it works for you, let me know and I'll update the 'master' and resubmit. Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/22/14 07:01 PM (11 years ago)
I have a breakpoint at the ViewWillUnload in sw_smugmshloc.m However it is not executed even when I exit screen via NavBar back button to home menu, or Tab Home button? - so adding code here has no effect. To see the behavior: (with xcode running on iphone) If you un-comment your lines in the doUpdate, do you keep seeing debug statements with the Lat and Long after you leave the screen (when phone is moved slightly)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/22/14 07:13 PM (11 years ago)
viewWillDisappear is a different method, and should be placed 'outside' of any other method. This method should run when you go off to another screen… Cheers! -- Smug
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/22/14 10:46 PM (11 years ago)
Now I get what you meant. Thanks for explaining. Smug- That did it!! My battery thanks you ;) -(void) viewWillDisappear:(BOOL)animated { [self stopUpdating]; }
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/22/14 11:23 PM (11 years ago)
I'll make an update soon. Cheers! -- Smug
 

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.