开发者社区 问答 正文

ios8的推送该怎么写

我想知道ios8 的推送代码有没有三方,有的话请大神给个网址或者能把推送的代码直接在回复中贴出,谢谢啦

展开
收起
杨冬芳 2016-06-27 18:44:39 1680 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业

    我给个第三方的平台给你,里面的推送sdk你可以直接调用的,非常方便

    http://www.bmob.cn/spread/redirect/?sid=df391636b0c871545fc0

    /**
     *  注册通知
     */
    - (void)registerRemoteNotification
    {
    #if !TARGET_IPHONE_SIMULATOR
        UIApplication *application = [UIApplication sharedApplication];
        //iOS8 注册APNS
        if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
            [application registerForRemoteNotifications];
            UIUserNotificationType notificationTypes = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
            [application registerUserNotificationSettings:settings];
        }else{
            UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeBadge |
            UIRemoteNotificationTypeSound |
            UIRemoteNotificationTypeAlert;
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
        }
    #endif
    }
    2019-07-17 19:47:58
    赞同 展开评论
问答标签:
问答地址: