我有一个带有新闻Feed的应用。人们可以在Feed中收藏最喜欢的帖子。但是当有人按下收藏夹按钮时,会出现一个奇怪的警报视图,显示一条消息。该消息是否实际用于推送通知目的。它不是推送通知,而是显示为警报视图。这是iOS错误还是推送通知服务的问题?我该如何解决这个问题?
更新
这是我的推送通知方法
#pragma mark - Push notification methods
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
[[NSUserDefaults standardUserDefaults] setValue:token forKey:@"device_token"]
;
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"content---%@", token);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
NSLog(@"Failed!!");
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
NSLog(@"%@", userInfo);
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
NSLog(@"Local one");
}
更新2
此处,我如何注册推送通知。
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]){
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
}
我也意识到,iPhone 6 Plus(10.1.1)中没有发生这种情况。它发生在iPhone SE(10.0.2)中。
答案 0 :(得分:0)
也许您可以搜索项目中的通知名称, 查找其他控制器是否也收到通知
答案 1 :(得分:0)
对于iOS 10推送通知这些方法 我想这种方法显示警报视图
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
completionHandler(UNNotificationPresentationOptionAlert);
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
}