iOSとプッシュ通知は初めてです。私のPNSは開発モードでうまく機能しており、本番用に使用したいと考えています。
本番モードで行うためのすべての手順を教えてください。また、本番モードでプッシュ通知が受信されたかどうかをテストするにはどうすればよいですか??
ベロコードは開発モードでうまく機能しています...
#pragma mark - Push Notifications Methods
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *tokenStr = [deviceToken description];
// Separete Your device token with <,< and blanksapace
NSString *pushToken = [[[tokenStr
stringByReplacingOccurrencesOfString:@"<" withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString:@" " withString:@""];
sclass.deviceToken = pushToken;
// Save the token to server
NSString *urlStr = [NSString stringWithFormat:@"http://www.vijaywebsolutions.com/Development_FTP/webservice/webservices.php?deviceToken=%@",pushToken]; // Passing token to URL
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self]; // Support to perform URLrequest
if( theConnection )// checking connection successfull or not
{
webData = [NSMutableData data];
NSLog(@"device token is %@", pushToken);
}
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (application.applicationState == UIApplicationStateActive) // If app is running and you got notification then show it
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification" message:[NSString stringWithFormat:@"You Have a Notification :\n%@",userInfo[@"aps"][@"alert"]]delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
NSLog(@"Payload: %@", userInfo);
imageURL = userInfo[@"aps"][@"alert"];
MainViewController *MvC=[[MainViewController alloc]initWithNibName:@"MainViewControlleripad" bundle:nil];
self.window.rootViewController=MvC;
[MvC sshowansimage:imageURL];
}