내 현재 프로젝트 중 하나에 Push Notification
을 설정했습니다. 나는 푸시 알림에 필요한 모든 지시를 따랐습니다. 저 [태그 : ios7]에서 잘 작동하지만 7.1
내 배경 모드에서 응용 프로그램을 실행할 때 배지 업데이트에서 문제가 발생했습니다.ios7.1 : 푸시 알림 배지 업데이트 문제
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSString *str = [NSString
stringWithFormat:@"%@",deviceToken];
NSLog(@"%@",str);
self.deviceToken = [NSString stringWithFormat:@"%@",str];
NSLog(@"dev --- %@",self.deviceToken);
self.deviceToken = [self.deviceToken stringByReplacingOccurrencesOfString:@"<" withString:@""];
self.deviceToken = [self.deviceToken stringByReplacingOccurrencesOfString:@" " withString:@""];
self.deviceToken = [self.deviceToken stringByReplacingOccurrencesOfString:@">" withString:@""];
NSLog(@"dev --- %@",self.deviceToken);
}
그리고 responce을 얻기를 위해
-(void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
UIApplicationState state = [application applicationState];
// If your app is running
if (state == UIApplicationStateActive)
{
//You need to customize your alert by yourself for this situation. For ex,
NSString *cancelTitle = @"ok";
// NSString *showTitle = @"Get Photos";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:nil];
[alertView show];
}
// If your app was in in active state
else if (state == UIApplicationStateInactive)
{
}
[UIApplication sharedApplication].applicationIconBadgeNumber = [UIApplication sharedApplication].applicationIconBadgeNumber + [[[userInfo objectForKey:@"aps"] objectForKey: @"badge"] intValue];
}
우선 내 응용 프로그램이 땅에 다시 갈 때 didReceiveRemoteNotification
그래서 내가 전화 받고하지 않는 것이 있다는 것입니다 -을 :
내 코드는 다음입니다 검색을 한 후 다음을 입력합니다. -
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
및 설정 배경 모드 같은 : -
그건 내 모든 장치가 엑스 코드와 연결할 때 잘 작동하고 내가 응용 프로그램 테스트 푸시 알림을 실행하지만 난 장치 (iOS7.1)을 뽑았 때. 푸시 알림이 도착했지만 배지가 업데이트되지 않았습니다. 그렇지 않으면 배지가 백그라운드에서 업데이트되고 모든 메서드가 호출됩니다. 하지만 똑같은 일이 내 다른 장치에이 애플 리케이션을 테스트 iOS7
모두 잘 작동합니다.
어디에서 실수를했는지, 어디에서 잘못했는지 이해할 수 없습니다. 어떤 버그가 있거나 내가 무엇을 생각하는지 모르니, 제발 저를 도와주세요.
서버가'apn'에서 배지를 보내고 있습니까? – cojoj
위의 질문에서 언급 한 것처럼 내 옆에서 배지를 설정하고 있습니다. –
하지만 원격 알림을 사용 중입니다 ... 서버 측에서 배지를 관리하지만 사용자가 기기에서 관리하는 것은 아닙니다. – cojoj