12-12-2012 09:09 PM - edited 12-12-2012 09:11 PM
Hello all
My app is running on a Curve and a Bold, OS v5.0.0.973/979. I'm trying to register it to receive Push notifications and its failling.
I have the registration code running in its own thread, here's the run() method:
publicvoid run(){
ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor();
int port = Push Port from production registration email;
String appId = "ApplicationID from production registration email"
String bpasUrl = "PPG Base URL from production registration email";
byte serverType = PushApplicationDescriptor.SERVER_TYPE_BPAS;
PushApplicationDescriptor pad = new PushApplicationDescriptor(appId,
port, bpasUrl, serverType, ad);
PushApplicationStatus pushApplicationStatus = PushApplicationRegistry.getStatus(pad);
byte pasStatus = pushApplicationStatus.getStatus();
if (pasStatus == PushApplicationStatus.STATUS_ACTIVE) {
log("PUSH already registered");
} else if (pasStatus == PushApplicationStatus.STATUS_PENDING) {
log("PUSH registration PENDING");
} else {
try{
PushApplicationRegistry.registerApplication(pad);
}
catch(IllegalArgumentException iae){
log("error);
}
}
}
I've tried starting this Thread from 2 different places in my class which I've defined as:
public class MyApp extends UiApplication implements PushApplication
I've tried starting it from MyApp constructor and from a method after
enterEventDispatcher() is executed.
Is it required to do push registration in a separate Thread? I've seen examples where push registration is done from within UiApplication and ones where its done in a different Thread. Does it matter?
I understand I cannot post the actual values from the production registration email, but I've used the row labels from the email in the section titled:
Application Credential (for use in your client application):
Am I using them in the right places in the registration code?
In addition, I've seen examples that use the PushApplicationReigstry methods as the example above does and I've also seen them actually using HttpConnection and InputStream/OutputStream. Does it matter?
Control does make it back to MyApp and makes it to my onStatusChange() method defined as:
public void onStatusChange(PushApplicationStatus pushAppStatus) {
String message = null;
byte bpsStatus = pushAppStatus.getStatus();
byte regReason = pushAppStatus.getReason();
String error = pushAppStatus.getError();
boolean simChanged = false;
String logStatus = "Unknown " + bpsStatus;
switch( bpsStatus ) {
case PushApplicationStatus.STATUS_ACTIVE:
setPushRegistered(true);
if( thread == null ) {
thread = new MessageReadingThread();
thread.start();
}
logStatus = "Active";
break;
case PushApplicationStatus.STATUS_FAILED:
logStatus = "Failed";
switch( pushAppStatus.getReason() ) {
case PushApplicationStatus.REASON_SIM_CHANGE:
simChanged = true;
message = "Not registered due to SIM change";
break;
case PushApplicationStatus.REASON_API_CALL:
message = "Not registered due to API call?";
break;
case PushApplicationStatus.REASON_REJECTED_BY_SERVER:
message = "Not registered due to rejection by server";
break;
case PushApplicationStatus.REASON_NETWORK_ERROR:
message = "Not registered due to network error";
break;
case PushApplicationStatus.REASON_INVALID_PARAMETERS:
message = "Not registered due to invalid parameters";
break;
}
break;
case PushApplicationStatus.STATUS_NOT_REGISTERED:
logStatus = "Not Registered";
switch( pushAppStatus.getReason() ) {
case PushApplicationStatus.REASON_SIM_CHANGE:
simChanged = true;
message = "Not registered due to SIM change";
break;
case PushApplicationStatus.REASON_API_CALL:
message = "Not registered due to API call?";
break;
case PushApplicationStatus.REASON_REJECTED_BY_SERVER:
message = "Not registered due to rejection by server";
break;
case PushApplicationStatus.REASON_NETWORK_ERROR:
message = "Not registered due to network error";
break;
case PushApplicationStatus.REASON_INVALID_PARAMETERS:
message = "Not registered due to invalid parameters";
break;
}
break;
case PushApplicationStatus.STATUS_PENDING:
logStatus = "Pending";
break;
}
log(" message="+message);
}
I'm getting PushApplicationStatus.STATUS_FAILED.
Is it reasonable to analyze pushAppStatus.getReason() at that point? I've seen examples of code that doesn't examing pushAppStatus.getReason() when PushApplicationStatus.STATUS_FAILED is received.
If it is reasonable to call pushAppStatus.getReason() at this point, I got PushApplicationStatus.REASON_REJECTED_BY_SERVER
In addition, I believe I've seen examples of this code using using HttpConnection and InputStream/OutputStream. Does that matter?
Is there a period of time after receipt of the production registration email before the values in the email are valid/accessible?
I've also read where where Push Registration can only be done via BIS thru the carrier network accessed via wifi. Is there any truth to this? Can Push Registration be done via BIS thru the local network accessed via wifi?
Help!
Mark
Solved! Go to Solution.
12-13-2012 09:03 AM
I got it fixed, but almost by accident.
I started wondering if I an HttpConnection based registration method would be more appropriate than the PushApplicationRegistry method I had been using. At least half of the examples out there do not use PushApplicationRegistry.
So I started to reimplement my registration method based on PushAgent.java I found here: http://supportforums.blackberry.com/t5/BlackBerry-
I noticed it appended "mss/PD_subReg" to the url. Since I had nothing to lose, I appended "mss/PD_subReg" to the url I received from RIM confirming the move of our app to production. The was in a section called "Application Credentials (for use in your client application)" and was labelled "PPG Base URL**"
The ** is a footnote saying its for production use only.
Everything started to work just fine at that point.
I'm just curious, I spent a day combing thru documentation and couldn't find any references to this outside of the sample program at the link I posted. Is there anywhere else I could have looked?
12-13-2012 09:28 AM
12-13-2012 10:46 AM
Simon
Fair enough. First THANK YOU for simplifying that example. I've stared at RIMs example for a few hours and got nowhere, in addition to scouring the forums here. The forums at least, showed it was a fairly common problem.
Hopefully, posting what worked for me will make someone else's life easier.
Mark
12-13-2012 10:55 AM
12-13-2012 11:01 AM
i've marked it.
that reminds me, i should do that to all the other threads i've made.