????Provider??APNS???????????ο?javapns??NotificationTest.java???????ο??????????
????(1)??????????????????
????Push.badge(2?? keystore?? password?? false?? "7bb8d508e32df651c6c239439737dbd40a88d2461ad2ac1e5dbe49ecea5ccc67");
???????У?2????????????
????String keystore = "PushCertificates.p12";     //P12?????·????
????String password = "sosoimage";                //P12?????????
????false?????????ò??????????????????????????true.
????"7bb8d508e32df651c6c239439737dbd40a88d2461ad2ac1e5dbe49ecea5ccc67"???????ò?????Provider??DeviceToken????????????????String[]?????????????????Push?????
????(2)??????????????????
????Provider??????????Push???Message?????????????????????Message?????????????????????????
????Push.alert("A Message"?? keystore?? password?? )false?? "7bb8d508e32df651c6c239439737dbd40a88d2461ad2ac1e5dbe49ecea5ccc67");
????(3)?????
?????????????Push????︽???????????Message?? ???????????????????′???.
????PushNotificationPayload payload = PushNotificationPayload.complex();
????payload.addAlert("A Message");
????payload.addBadge(2);
????payload.addSound("test.aiff");
????Push.payload(payload?? ?? keystore?? password?? false?? "7bb8d508e32df651c6c239439737dbd40a88d2461ad2ac1e5dbe49ecea5ccc67");
?????????????п???????????Exception??????????????????????÷??????ο? http://code.google.com/p/javapns/
????IOS?????????????APNS?????????
????(1)??????δ???????????????????????AppDelegate?е?didFinishLaunchingWithOptions??????????????????£?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
NSDictionary* payload = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (payload)
{
...
}
...
}
????(2)?????????????У?????????????????????????????????????????????????????????????????????????????????????AppDelegate??didReceiveRemoteNotification???????????????????д????????????????????????????????
????- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)payload
????{
????...
????}
????(3)???????????????????????????NSDictionary??????????????ο????′???
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)payload
{
NSLog(@"remote notification: %@"??[payload description]);
NSString* alertStr = nil;
NSDictionary *apsInfo = [payload objectForKey:@"aps"];
NSObject *alert = [apsInfo objectForKey:@"alert"];
if ([alert isKindOfClass:[NSString class]])
{
alertStr = (NSString*)alert;
}
else if ([alert isKindOfClass:[NSDictionary class]])
{
NSDictionary* alertDict = (NSDictionary*)alert;
alertStr = [alertDict objectForKey:@"body"];
}
application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
if ([application applicationState] == UIApplicationStateActive && alertStr != nil)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Pushed Message" message:alertStr delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}