2017-01-03 71 views
0

我有一個新聞源的應用程序。人們可以在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)中。

enter image description here

+1

如果你製作的應用程序,我敢肯定你也做了這個對話框。推送通知在應用程序運行時不會顯示爲通知。 –

+0

整整一天,我檢查了我身邊的一個錯誤。但我沒有找到那樣的事情。 – codebot

+0

它是在您的應用程序實現中,因爲這是應用程序接收通知的地方。 –

回答

0

也許你可以在你的項目中搜索通知名字, 找到其他控制器是否還會收到通知

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{ 
    }