AJAX Request on mobile only works when wifi is available?

Ideas and discussion about publishing and distributing your games

Post » Wed Sep 10, 2014 2:57 am

As the title reads, I'm retrieving my highscore table from a php file on my webserver, and it doesn't work when the player does not have wifi. Any ideas what the problem could be?
B
19
S
5
G
2
Posts: 72
Reputation: 1,846

Post » Wed Sep 10, 2014 6:46 am

You need wifi to connect to internet to fetch the file which is on your webserver which is online, and can't be accessed without an internet connection. Anything shipped with game is offline. Anything external requires internet.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Wed Sep 10, 2014 8:52 pm

But we still have 4G and LTE. Why can't my game utilize this technology?
B
19
S
5
G
2
Posts: 72
Reputation: 1,846

Post » Wed Sep 10, 2014 9:14 pm

I know mobile can either disable 3g/4g completely to avoid costs, also, did the On error trigger?
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu Sep 11, 2014 3:35 am

I made sure the 3g/4g wasn't disabled. The app is already out, and only my friends who have crappy wifi have this problem. It may be related to the leaderboard php code, but I'm not sure. If I upload it can you take a look?

Edit: I reread all of the code, and added error messages for every failed if statement...however no data is returning. This leads me to believe that the AJAX plugin doesn't work on mobile. I'm using AJAX RSA plugin, for the encryption.
B
19
S
5
G
2
Posts: 72
Reputation: 1,846

Post » Thu Sep 11, 2014 6:26 am

AJAX does work on mobile

Okay pulling at straws...

Have you tried adding this to your php file
Code: Select all
header('Access-Control-Allow-Origin: *');

You also need to check cross-domain security restrictions
Read about it here

Some phones "I think" can block fetching data for security reasons. I'm really not very clued up on mobile security settings.
But if it works on wifi, which i know it does. It also works on my 3g, but I've set my phone to use either wifi(when available) or 3g so it always has access to internet. Some apps I have turned off 3g to save $$ so it could be users mobile settings.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Sep 11, 2014 11:01 am

I already have that header in the php file, and my cellular data for my app is turned on in settings. This is on iphone btw.
B
19
S
5
G
2
Posts: 72
Reputation: 1,846

Post » Thu Sep 11, 2014 11:32 am

Whack wrote:I already have that header in the php file, and my cellular data for my app is turned on in settings. This is on iphone btw.


You used cocoonjs to port to iOS I presume. It wouldn't surprise me at all to find the issue is there.
I haven't done a iphone app in awhile because cocoonjs isn't an option, has never been.

I presume the preview worked fine... therefore the issue is with cocoonjs (if you used it)
Sorry, I haven't a clue.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Sep 11, 2014 1:56 pm

AJAX should work fine over cell data connections. There is absolutely nothing different you need to do as a developer, everything is handled by the OS. However cell data connections can be really flakey and simply not respond for a while even with good signal (at least in my experience with my own phone...) I think you just might need to be patient!
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Thu Sep 11, 2014 5:45 pm

Ashley wrote:AJAX should work fine over cell data connections. There is absolutely nothing different you need to do as a developer, everything is handled by the OS. However cell data connections can be really flakey and simply not respond for a while even with good signal (at least in my experience with my own phone...) I think you just might need to be patient!


@ashley so do you mean that the cell data connection cannot connect to my website, at least yet? How long would I need to wait. It's been at least a month.
B
19
S
5
G
2
Posts: 72
Reputation: 1,846

Next

Return to Distribution and Publishing

Who is online

Users browsing this forum: No registered users and 1 guest