Discussion Forums  >  Self Hosted Control Panels

Replies: 8    Views: 223

chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
05/09/13 09:26 PM (12 years ago)

strange issue with push notifications: always registers as design

So I'm trying to set apn up for a client. I got the update with the correct profile approved in the app store, and the device seems to be registering. However, when my devices (iphone 4s and ipad 1st-gen) register on my control panel, they register in "Design" mode. I've tried deleting the apps and installing them anew from the app store. I made sure my config.txt says: "currentMode":"Live", But still, it shows up as "Design". If I try to send a message to live devices, it tells me there are none registered. If I try to send one to design devices, it says it sends fine, but I never receive them. BUT, if I manually edit the table on my database through myPHPadmin and change it from Design to Live for one of my devices, then I can receive messages just fine when I use the control panel. I'm not sure why this is happening. I know I accidentally sent the project to the app store with "Design" in the config.txt, but the config.txt from my dataURL clearly says "Live". (And yes I'm serving up the config.txt manually, not via the control panel).
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/09/13 10:23 PM (12 years ago)
okay - I did a bit of debugging and found out some more info. Still not sure how helpful this is though. the api/inc_validateRequest.php file is what gathers the info about the currentMode property. That section of code is near the top of that file and looks like this: //$_POST or $_GET variables sent with the request... if(isset($_SERVER["REQUEST_METHOD"])){ switch ($_SERVER["REQUEST_METHOD"]){ case "POST": $clientVars["requestMethod"] = "POST"; foreach($_POST as $key => $value){ $clientVars[$key] = $value; } break; case "GET": $clientVars["requestMethod"] = "POST"; foreach($_GET as $key => $value){ $clientVars[$key] = $value; } break; } } //done getting client variables passed to the API request ////////////////////////////////////////////////////////////////////////////// For some reason, this returns the value of "Design", which comes from the "GET" method. This isn't surprising - the php looked solid to me. But for some reason the code in the app seems to be sending the wrong value along. I can verify that the online config.txt has been downloaded, so why would it still be sending the wrong value?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/10/13 01:23 AM (12 years ago)
Have you tried parse? I know this doesnt help your issue here but I find parse so simple and effective. I dont know anything about push on BT but how does a client send a push? Obviously with parse you can set up an account for them and off they go.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
05/10/13 01:45 AM (12 years ago)
Hi @Chris1, I've had the same problems - http://www.buzztouch.com/forum/thread.php?tid=7FB1EEB0862E51460C6E6DD I was unable to find a solution and went with Parse. I seems to me it affects some people but not others and is a problem on Self Hosted or Buzztouch hosted.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/10/13 05:09 AM (12 years ago)
I don't really want to mess with a third-party solution like Parse unless I have to. Like I mentioned, my devices are registering...just in the wrong mode. I have another app that went live a couple days ago and it works just fine. I suppose I can edit the php file that handles registration to check if the app guid matches this one app, then register live. But I'd prefer getting to the bottom of it. :)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/10/13 05:14 AM (12 years ago)
AlanMac - I'm curious as to whether your devices were registering in the wrong mode or not at all?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/10/13 06:19 AM (12 years ago)
Okay - I think I figured it out. Turns out all I needed was a good night's sleep! :) In the appDelegate file, under the -(void)loadAppData{...} method is the following which tells the server whether to register in live or design mode: ////////////////////////////////////////////////////////////////// //check for cached version of configuration data if(([BT_fileManager doesLocalFileExist:self.saveAsFileName]) && ([myVersion isEqualToString:savedVersionNumber])){ //read the configuration data from the cache... self.configData = [BT_fileManager readTextFileFromCacheWithEncoding:self.saveAsFileName encodingFlag:-1]; //determine what "mode" we're in from the bundle data... if([BT_fileManager doesFileExistInBundle:bundleFileName]){ NSString *bundleData = [BT_fileManager readTextFileFromBundleWithEncoding:configurationFileName encodingFlag:-1]; SBJsonParser *parser = [SBJsonParser new]; id jsonData = [parser objectWithString:bundleData]; if(jsonData){ if([[jsonData objectForKey:@"BT_appConfig"] objectForKey:@"BT_items"]){ NSArray *tmpItems = [[jsonData objectForKey:@"BT_appConfig"] objectForKey:@"BT_items"]; NSDictionary *thisApp = [tmpItems objectAtIndex:0]; if([thisApp objectForKey:@"currentMode"]){ [self setCurrentMode:[thisApp objectForKey:@"currentMode"]]; } }//BT_items }//jsonData } //log... [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"Using configuration data from application cache.%@", @""]]; }else{ ////////////////////////////////////////////////////////////////// That code basically says "get the design/live mode from the config file in the bundle, and ignore whatever comes through over the cloud". In my case, since I accidentally shipped with the config file saying "design", it has no chance to register as live. It will take another update to the app store to fix the issue. In the mean time, I guess I'll modify the php file handling the registration.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
05/10/13 08:01 AM (12 years ago)
Hi Chris, my devices were registering fine if the config was set to 'design' mode, but not at all if the same app had the config file set to 'live' mode. I wondered if code-signing has any influence?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/10/13 08:04 AM (12 years ago)
Possibly. I still have more to learn about how the code is working.
 

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.