Няма описание

FKPushSettingViewModel.m 2.1KB

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