iOS成长之路-关于推送

 

  前一段时间做的项目里面需要用到极光推送,后面客户提出要求还需要在设置里面家推送开关,所以就查了很多资料,下面是一点成果。

一.我暂时还没发现有推送开关的苹果应用,一般的做法是在获取当前推送的状态显示在推送里面,然后提示用户在设置里面开关推送。qq,微信目前都是这么做的。

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

    {

        

        [[UIApplication sharedApplication] registerForRemoteNotifications];

        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];

        

        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

        UIUserNotificationType types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;

        if (types == UIUserNotificationTypeNone) {

            NSLog(@"没有开启推送");

            self.npns = @"已关闭";

        }else{

            self.npns = @"已开启";

        }

    }

    else

        {

            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:

             (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];

            UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

            if (UIRemoteNotificationTypeNone == types) {

                NSLog(@"没有开启推送");

                self.npns = @"已关闭";

            }else {

                self.npns = @"已开启";

            }

        }


- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{

    if (section == 0) {


    NSString *la = @"请在iPhone设置”-“通知中进行修改。";

    return la;

    }

    return nil;

}


二.推送声音的设置,推送声音需要与服务器联调,服务器传过来的json里面有sounds字段
   这里参考一下这位大神的文章  http://blog.csdn.net/like7xiaoben/article/details/9001806     
       服务器端传过来什么字段,客户 端就播放对应字段名字的声音文件。                          
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值