0

我想从iOS发送推送通知到android工作正常。但不是从iOS到iOS/Android到iOS。我正在使用parse.com。当我从iOS发送到iOS时,推送状态显示为0。 didReceiveRemoteNotification没有被调用。推送通知只能发送从ios到Android不从ios到ios/android到ios

// Register for Push Notitications 
CGFloat systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; 
if(systemVersion > 8.0) 
{ 
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | 
                UIUserNotificationTypeBadge | 
                UIUserNotificationTypeSound); 
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil]; 
    [application registerUserNotificationSettings:settings]; 
    [application registerForRemoteNotifications]; 
} 
else 
{ 
    // Register for push notifications 
    [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | 
    UIRemoteNotificationTypeSound]; 
} 

在此先感谢。

+0

请检查您的推送证书,因为您没有收到IOS通知。这意味着,无论是在证书或服务器上的代码问题。 – Hindu

回答

0

也许“if(systemVersion> 8.0)”应该是“if(systemVersion> = 8.0)”。无论如何,在这里你有我的代码使用respondsToSelector。

// Register for Push Notitications, if running iOS 8 
UIApplication* application=[UIApplication sharedApplication]; 
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { 
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound); 
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil]; 
    [application registerUserNotificationSettings:settings]; 
    [application registerForRemoteNotifications]; 

} else { 
    // Register for Push Notifications before iOS 8 
    [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; 
}