ios - Data not sent from a background via 3G -


i have application sends data server while app in background. here code responsible data sending:

-(bool) sendstats: (mcstatssender*) val{      if(![self checkinternet]){ //using reachability here          return false;     }      nsdictionary *inputdata = [nsdictionary dictionarywithobjectsandkeys:                                self.propertya.value, "key1",                                val.data, "key2",                                nil];       [mynetworkmanager dorequest:[myrequestmanager createwithstringanddictionary:my_url data:inputdata handler:myhandler user:val]];     return true; } 

so inputdata simple dictionary strings.

a method dorequest based on nsurlsession , looks this:

-(void) dorequest: (mcrequest*) request{      [tasks addobject:request];      if(m_session == nil){         nsurlsessionconfiguration* config = [nsurlsessionconfiguration backgroundsessionconfigurationwithidentifier:[nsstring stringwithformat:@"key-%lu",reqid]];         m_session = [nsurlsession sessionwithconfiguration:config delegate:self delegatequeue:nil];     }      nsurlsessiondatatask* task = [m_session datataskwithrequest:request.generatedrequest];     request.reqid = task.taskidentifier;     [task resume];   } 

as said, everything works through wi-fi, app goes background, , after few minutes, custom bluetooth device sends data , wakes application suspended mode. after data has been received ios application, fails send server if device connected on 3g. positive data sent via bluetooth received because stored in local database.

also there 1 other important fact. if application run through xcode, if device connected on 3g, application send data background. this, run app, tap home button put background.

don't know difference , why app acts differently when attached cable mac, , why data not sent via 3g (or 2g) ?

additional info:

i not trying upload file, rather send json server.

it seems power usage. background upload offered url session convenience, , it's offered @ discression of os - offers send data gets choose when.

things affect when data sent include wether device connected power, quality of data connection (how long , how power take send data), else device doing (can combine multiple uploads)...

so, can't guess or rely on task being actioned @ particular time while in background.

this kind of testing should done on device only, , not connected xcode because influences test. instead, use charles proxy log network requests , use device, leaving periods of time , maybe opening , using other app. should see data sent eventually, have wait.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -