Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Location events in iOS
Started by zalacans Oct 27 2015 02:27 PM

6 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

zalacans

[GLOBAL: userInfoPane.html]
zalacans
  • Observer

  • 26 posts
  • Corona SDK

Hi all,

 

I need some help, I don't understand why my app isn't generating location events on iOS, or even on the xcode simulator. It also doesn't ask for user permission, but it should, right?

It works on Android and windows simulator (even throws 3 events at once on startup).

 

I hope it's not some obvious configuration issue, because I've checked the Location documentation multiple times. But help me out.

 

Summarized code. You can see I tried lowering the threshold for the first event, but it didn't change anything:

-----------------------------------------------------------------------------
-- Location routine
-----------------------------------------------------------------------------

-- Setup location hardware
system.setLocationAccuracy( 10 );
system.setLocationThreshold( 1 );  -- first event only

-- Debug text (global)
debugBox = display.newText({
	-- the args
});

-- Location event handler
local debugCount = 0;
local netCount = 0;
local function locationHandler( locEvent )

    -- Increase threshold after first event
    system.setLocationThreshold( 100 );
    
	debugCount = debugCount + 1;

	if ( debugCount == 1 ) then
		debugBox.text = debugBox.text .. "location event\n";
		if ( locEvent.errorCode ) then
			debugBox.text = debugBox.text .. locEvent.errorMessage;
		end
	end

	-- If no error
	if ( not locEvent.errorCode ) then
	
		if ( debugCount == 1 ) then
			debugBox.text = debugBox.text .. "no error\n";
		end
	
		-- some other stuff involving network requests
		
	end
end
-- Location event listener
Runtime:addEventListener( "location", locationHandler );



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,253 posts
  • Enterprise

Can you post your build.settings?

 

Rob



[TOPIC: post.html]
#3

zalacans

[GLOBAL: userInfoPane.html]
zalacans
  • Observer

  • 26 posts
  • Corona SDK

Hi Rob,

 

build.settings:

settings =
{
	orientation =
	{
		default = "portrait",
		supported = { "portrait", "portraitUpsideDown" },
	},
	android = 
	{
		versionCode = 20000,
		coronaWindowMovesWhenKeyboardAppears = true,
		usesPermissions =
		{
			"android.permission.INTERNET",
			
            -- Permission to retrieve current location from the GPS
            "android.permission.ACCESS_FINE_LOCATION",

            -- Permission to retrieve current location from WiFi or cellular service
            "android.permission.ACCESS_COARSE_LOCATION",
			
            -- "android.permission.GET_ACCOUNTS",
            -- "android.permission.RECEIVE_BOOT_COMPLETED",
            -- "com.google.android.c2dm.permission.RECEIVE",
            -- ".permission.C2D_MESSAGE",
		},
        -- permissions =
        -- {
            -- { name = ".permission.C2D_MESSAGE", protectionLevel = "signature" },
        -- },
	},
    plugins =
    {
        ["facebook"] =
        {
            publisherId = "com.coronalabs"
        },
		["plugin.OneSignal"] =
		{
			publisherId = "com.onesignal",
		},
		["plugin.google.play.services"] =
		{
				publisherId = "com.coronalabs",
				supportedPlatforms = { android=true, ["android-kindle"]=true },
		},
	},
    iphone =
    {
        plist =
        {
            -- CFBundleDisplayName = "My Corona App",
            -- CFBundleName = "My Corona App",
            -- MinimumOSVersion = "7.0",
            UIPrerenderedIcon = false,
            UIApplicationExitsOnSuspend = false,
            UIStatusBarHidden = true,
            UIAppFonts = { "FuturaBT-Medium.ttf","FuturaBT-Bold.ttf" },
            CFBundleIconFiles = {
                "Icon",
                "Icon-60",
                "Icon-72",
                "Icon-76",
                "Icon-Small-40",
                "Icon-Small-50",
                "Icon-Small",
            },
            UILaunchImages = {
                {  -- iPhone 4 Portrait
                    ["UILaunchImageMinimumOSVersion"] = "7.0",
                    ["UILaunchImageName"] = "Default",
                    ["UILaunchImageOrientation"] = "Portrait",
                    ["UILaunchImageSize"] = "{320, 480}"
                },
                {  -- iPhone 5 Portrait
                    ["UILaunchImageMinimumOSVersion"] = "7.0",
                    ["UILaunchImageName"] = "Default-568h",
                    ["UILaunchImageOrientation"] = "Portrait",
                    ["UILaunchImageSize"] = "{320, 568}"
                },
                {  -- iPad Portrait
                    ["UILaunchImageMinimumOSVersion"] = "7.0",
                    ["UILaunchImageName"] = "Default-Portrait",
                    ["UILaunchImageOrientation"] = "Portrait",
                    ["UILaunchImageSize"] = "{768, 1024}"
                },
                {  -- iPhone 6 Portrait
                    ["UILaunchImageMinimumOSVersion"] = "8.0",
                    ["UILaunchImageName"] = "Default-667h",
                    ["UILaunchImageOrientation"] = "Portrait",
                    ["UILaunchImageSize"] = "{375, 667}"
                },
                {  -- iPhone 6 Plus Portrait
                    ["UILaunchImageMinimumOSVersion"] = "8.0",
                    ["UILaunchImageName"] = "Default-736h",
                    ["UILaunchImageOrientation"] = "Portrait",
                    ["UILaunchImageSize"] = "{414, 736}"
                },
            },
            FacebookAppID = "",  --replace XXXXXXXXXX with your Facebook App ID
            CFBundleURLTypes =
            {
                { CFBundleURLSchemes = { "", } }  --replace XXXXXXXXXX with your Facebook App ID
            },
			UIBackgroundModes = {"remote-notification"},
        },
    },
}


[TOPIC: post.html]
#4

zalacans

[GLOBAL: userInfoPane.html]
zalacans
  • Observer

  • 26 posts
  • Corona SDK

Hi! Any news on this?

-Sam



[TOPIC: post.html]
#5

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Sam,

As usual in cases like this, I suggest that you test out one of our sample apps to see if the issue is duplicated.

 

https://github.com/coronalabs/samples-coronasdk/tree/master/Hardware/GPS

 

This is also located in your local Corona SDK application folder in the "SampleCode > Hardware" folder.

 

Brent



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,253 posts
  • Enterprise

I think iOS 9 may require you to have this key in your plist table in build.settings:

 

NSLocationWhenInUseUsageDescription = "This app uses maps and GPS when active to determine where to report weather for.",

 

The text you write yourself. I would be willing to bet that your console log from the device is complaining about that key not being there.

 

Rob



[TOPIC: post.html]
#7

zalacans

[GLOBAL: userInfoPane.html]
zalacans
  • Observer

  • 26 posts
  • Corona SDK

Well Gents,

I couldn't try it out because now I'm running into a load of other issues, which I've put in their own topic:

https://forums.coronalabs.com/topic/60136-bunch-of-errors-sdk-mismatch-unusable-profiles/




[topic_controls]
[/topic_controls]