Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetInternetState Is Always = 1 on IOS

Author
Message
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 03:41
I have a button in my AppGameKit app that when clicked will only open up another function if GetInternetState() = 1.

Well it worked well on all Android Devices and I tested live by turning off and on WiFi and GetInternetState was = to the correct value.

On all of my IOS devices when the WiFi is turned off GetInternetState still = 1. WHY?

I went so insane I even walked 3 blocks the street to make sure I had no internet connection. (lol)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Apr 2014 05:30
What version of AppGameKit are you working with (V1 or V2, and which of the released version within that)?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 05:37
Version 1 : Build 108
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 05:46
And with that what version of AppGameKit do you recommend me to use?

GetInternetState not working on IOS is killing my time to submit my app!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Apr 2014 10:51
Silly question, but have you got mobile data on the phone switched on? That would give you a permanent connection.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 13:51 Edited at: 4th Apr 2014 14:01
This is happening with IPAD also which I assume would not have mobile data option.
Actually realized this problem when I was in car driving with my daughter and she was
playing my game on her IPAD and tried to access my Leaderboard without warning from
my code which checks if internet connection=1. All of my Http code linked to my PHP
scripts checks this value also before executing. This is very strange.

Created a test app with one line of code checking internet connection and same results.
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 15:15
Also, tested on 3 IPADS (none mobile devices) with WiFi turned OFF and Airplane Mode ON and still: GetInternetState() = 1
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th Apr 2014 18:36
Amazingly I never noticed this!
It is very possible though.
One last thing you could test: There is a setting in the iOS devices developer options where you can change the connection quality type to various things like poor quality wifi.
However, you need multiple levels of failure checking on your
attempts to communicate with your server.
Level 1 - Is internet on - if so attempt connection
Level 2 - Is response ready within a reasonable amount of time? (I use GetHTTPResponseReady in conjunction with a timer to check for a 60 second time out).
Level 3 - If the response is ready then is the response a valid response?

With Level 3 there are many many ways to do this. If your PHP script is returning specific values then you know exactly what to test for. If your script is returning more complicated things then you have to test their structure or something like a checksum. Many of my scripts will do a combination of the two.
An example of testing for structure:
PHP output is
1,2,3,4,5,6,7,8,9
If we know we are always expecting 9 comma separated numbers then we can use the CountStringToken command to check if the returned data is valid.
A second method is to use checksums on the ends of the returned string. This way you know you have all of the data.
In that case say your script returns this:
45:1,2,3,4,5,6,7,8,9:45
You know you to expect 3 string tokens separated by :
Token 1 and 3 are your checksums.
If they match then you can assume that you've got your correct data. Then you can take the second string token and do whatever you need to do with it.

Always check to make sure you're getting what you expect to be getting from the server. Bits can get lost in transmission, but this should rarely be the case. The more frequent case is human error (i.e. your script outputs something not expected).

Conversely you should also sanitize / validate input to your PHP scripts. If you know what the app is sending (is this variable a number? is there a range? is ait a string? is there a max and min length? are there illegal characters I want to escape - YES). An important note at this point is that you should always make sure to validate your PHP script input to protect your server from SQL injection attacks. There's a lot of info on this on the internet and a list of characters that should be escaped or removed before inputting them into a SQL query.

So validate as much as possible!

Also, I think you've found a nifty little bug in AGK. You should report it to them with sample code.
https://code.google.com/p/agk/
Hopefully that thread will be attended to again once v2 is released.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 19:13
Perhaps I can create a simple function with http to return a simple value
from a php script that would always be the same and if that fails I would know
that there is no connection. Temporarily taking the place of internetstate until bug is fixed
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Apr 2014 19:17
I'm not sure that this is a bug. Most computers will report that they have an internet connection if the sockets are set up. It's more reliable to try to contact a site and report failure if you could not do that.

-- Jim - When is there going to be a release?
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 19:37
Well this simple little command is very important for anything
Sort of http code done in AGK. Without it working or another method
of knowing if there is an internet connection will cause many problems
with IOS apps. When ran on Android (I've tested) getinternetstate returns 0
immediately when I disconnect WiFi or disable mobile data.

I have honestly spent much more time working around IOS problems
with AppGameKit than actually writing my game. I know Ive heard many brag
about how great IOS is because of it being hacker proof but geez man
I'd rather develop for Android any day over IOS. Getting very painful not
to mention the time just waiting to get app reviewed with IOS. With Android
and Amazon publishing the most ive waited is 3 hours for an approved app.
AND NEVER HAD AN AppGameKit BUG with that said.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th Apr 2014 19:54
*jumps on iOS hate wagon*

Quote: "Without it working or another method
of knowing if there is an internet connection will cause many problems
with IOS apps."

Just check your returns from your server for appropriate data. It should be done anyway because of things like lost connection during data transfer. Or lost bits, etc, etc.

xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 4th Apr 2014 20:13
I also experience this on both a previously compiled iOS app and when running an app through the AppGameKit Player. It should be an easy fix and one that I feel is very important. Sure, you can attempt an HTTP request and analyze the response to see if a page is reachable, but it would help to have immediate response over whether the Internet is reachable to any capacity, rather than waiting for a timeout (which could also happen if the HTTP server you are requesting is down but not the user's network). As of iOS 6.0 there is a Reachability library that makes this very simple in native code.
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 4th Apr 2014 20:17
Napier yes you are right. Its just so frustrating knowing that with my short period of
time working with AppGameKit that ive literary had flawless results with the Android side of
things and spent so much time on the IOS side where a lot more money was invested.

And JimHawkins thanks for your reply but if that's the case the GetInternetState ()
Command should be changed to GetSocketState (). Entirely misleading to its real
functionality and has caused much frustration.

Why does it work perfectly to its meaning with Android devices?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Apr 2014 02:02
If I remember correctly Paul fixed this for me some time ago for PC/android, but I didn't have iOS to check. The problem was that it took about 30 seconds for the command to acknowledge that there was no connection. During this time it falsely reported that the connection existed.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 5th Apr 2014 05:47
I FIXED my issue with Naphier's suggestion once again. Just put in a dummy HTTP request
and if it timed out I set my variable InternetOK = 0 if not InternetOK = 1. My own
GetInternetState function.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Apr 2014 06:46
Glad you found a solution Not ideal, but it works! Compromise is very frequent in development.

Login to post a reply

Server time is: 2024-05-11 19:15:03
Your offset time is: 2024-05-11 19:15:03