Simple Black Berry Push Service (initiator) implementation
I guess one way or the other we most have heard about push notification. which now exist in most mobile OS out there, such as the Black berry, the Android, Iphone and Windows phone mobile. This blogging is about the Black berry server side push notification.
Below is the architectural design of the black berry push notification
and for more understanding and detail behind the architecture go hereBelow is the architectural design of the black berry push notification
Below is a sample simple server-side java push application to push messages. RIM provide API to help simplify the development of push message to the RIM server
public static void pushMsg() { IdGenerator l_idGenerator = new IdGeneratorImpl(); List<String> l_Lstaddresses = new ArrayList<String>(); l_Lstaddresses.add("<BB Pin>"); //l_Lstaddresses.add("push_all");//To push to all BB pin registered on your server. PushMessageControl l_pushMessageControl = new PushMessageControl(l_idGenerator,APP_ID, l_Lstaddresses); l_pushMessageControl.getPushId(); Content l_content = new TextContent("This is my push message Test pushid"); PapService l_papService = new PapServiceImpl(); PushSDKProperties properties = getProperties(); HttpClientImpl client = new HttpClientImpl(); client.setPushSDKProperties(properties); l_papService.setHttpClient(client); l_papService.setPushSDKProperties(properties); try { PushResponse response = l_papService.push(APP_ID, password, APP_ID, l_pushMessageControl, l_content); l_Strpushid = response.getPushId(); System.out.println("#PushId : " + l_Strpushid); System.out.println(response.getResult()); } catch (PushSDKException e) { e.printStackTrace(); } catch (BadMessageException e) { e.printStackTrace(); } catch (UnauthorizedException e) { e.printStackTrace(); }
} private static PushSDKProperties getProperties() { PushSDKProperties p = new PushSDKPropertiesImpl(); p.setPpgAddress(targetURL); p.setUsingPublicPush(true); p.setHttpIsPersistent(false); p.setHttpConnectionTimeout(60000); p.setHttpReadTimeout(120000); p.setUsingXmlParserDtdValidation(true); return p; }