我有一個新聞源的應用程序。人們可以在Feed中最喜歡的帖子。但是當某人按下最喜歡的按鈕時,會出現一條奇怪的警報視圖,並顯示一條消息。該消息實際上是用於推送通知的目的。它不是推送通知,而是顯示爲警報視圖。它是iOS錯誤還是推送通知服務的問題?我該如何解決這個問題?在iOS中顯示實時的奇怪警報視圖
UPDATE
這裏是我的推送通知方法
#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)中。
如果你製作的應用程序,我敢肯定你也做了這個對話框。推送通知在應用程序運行時不會顯示爲通知。 –
整整一天,我檢查了我身邊的一個錯誤。但我沒有找到那樣的事情。 – codebot
它是在您的應用程序實現中,因爲這是應用程序接收通知的地方。 –