相关疑难解决方法(0)

在iOS 9中注册通知

我用它来注册通知:

if application.respondsToSelector("registerUserNotificationSettings:") {
                let types:UIUserNotificationType = (.Alert | .Badge | .Sound)
                let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)

                application.registerUserNotificationSettings(settings)
                application.registerForRemoteNotifications()

            } else {
                // Register for Push Notifications before iOS 8
                application.registerForRemoteNotificationTypes(.Alert | .Badge | .Sound)
            }
Run Code Online (Sandbox Code Playgroud)

但它并不适用于iOS 9.

apple-push-notifications ios9 swift2

5
推荐指数
1
解决办法
4145
查看次数

使用FCM在ios中不显示远程通知

在部署FCM云消息传递之后,这是GCM云消息传递的升级版本,如https://developers.google.com/cloud-messaging/ios/client所述,因此我们使用pod将https集成到我们的应用中,如上所述https:// firebase.google.com/docs/cloud-messaging/notifications我跟进本教程中的每一步都是在状态背景状态活动状态下收到远程通知的情况,但我遇到的主要问题是通知确实出现在通知栏中这里是我正在使用的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {



    float ver = [[[UIDevice currentDevice] systemVersion] floatValue];

    if(ver >= 8 && ver<9)
    {
        if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
        {
            [[UIApplication sharedApplication] registerForRemoteNotifications];
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

        }
    }else if (ver >=9){

        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

        [[UIApplication sharedApplication] registerForRemoteNotifications];


    }
    else{
        //iOS6 and iOS7 specific code
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert];
    } …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c push-notification ios

5
推荐指数
1
解决办法
1559
查看次数