1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // FKPushSetViewModel.m
- // FirstLink
- //
- // Created by ascii on 16/8/15.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKPushSettingViewModel.h"
- #import "FKTargetConfigUtil.h"
- #import "FLControllerHelper.h"
- @implementation FKPushSettingViewModel
- + (BOOL)isPushEnable {
- UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
- return (UIUserNotificationTypeNone != setting.types);
- }
- - (NSString *)pushOnoffMessage {
- return [NSString stringWithFormat:@"关闭后,您将不会收到来自%@客户端的消息通知。如需开启,请去iPhone\"设置-通知\"功能中找到应用程序\"%@\"开启\"允许通知\"。", [FKTargetConfigUtil appName], [FKTargetConfigUtil appName]];
- }
- - (NSInteger)numberOfRowsInSection:(NSInteger)section {
- return [FKPushSettingViewModel isPushEnable] ? 1 : 2;
- }
- - (kPushSettingCellType)cellTypeForIndexPath:(NSIndexPath *)indexPath {
- return (indexPath.row == 0 ? kPushSettingCellTypePush : kPushSettingCellTypeDesc);
- }
- + (void)checkShowPushOpenAlert {
- if (![self isPushEnable]) {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"您关闭了\"剁手帮\"推送通知"
- message:@"关闭通知后,您无法再收到订单相关的物流、交易等重要提醒"
- preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
- UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"去开启" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
- [[UIApplication sharedApplication] openURL:url];
- }];
-
- [alert addAction:cancelAction];
- [alert addAction:defaultAction];
- [[FLControllerHelper currentController] presentViewController:alert animated:YES completion:nil];
- }
- }
- @end
|