GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ZYNetworkAccessibity/README.md at master · iOSCopder/ZYNetworkAccessibity

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
53 lines (30 loc) · 1.82 KB
/

README.md

Copy path

File metadata and controls

53 lines (30 loc) · 1.82 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

ZYNetworkAccessibity

Blog 介绍

##背景

一直都有用户反馈无法正常联网的问题,经过定位,发现很大一部分用户是因为网络权限被系统关闭,经过资料搜集和排除发现根本原因是:

  1. 第一次打开 app 不能访问网络,无任何提示
  2. 第一次打开 app 直接提示「已为“XXX”关闭网络」
  3. 第一次打开 app ,用户点错了选择了「不允许」或「WLAN」

对于第 1 种情况,出现在 iOS 10 比较多,一旦出现后系统设置里也找不到「无线数据」这一配置选项,随着 iOS 的更新,貌似被 Apple 修复了,GitHub 上面有 ZIKCellularAuthorization 其进行分析和提出一种解决方案,强制让系统弹出那个询问框。

但是第 2、3种情况现在 iOS 12 还经常有发生,对于这种情况,ZYNetworkAccessibity 提供了检测帮忙开发者引导用户打开网络权限。

用法

1、将 ZYNetworkAccessibity.h 和 ZYNetworkAccessibity.m 在合适的时机,比如 didFinishLaunchingWithOptions 开启,ZYNetworkAccessibity:

[ZYNetworkAccessibity start];

2、监听 ZYNetworkAccessibityChangedNotification 并处理通知

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChanged:) name:ZYNetworkAccessibityChangedNotification object:nil];
- (void)networkChanged:(NSNotification *)notification {
    
    ZYNetworkAccessibleState state = ZYNetworkAccessibity.currentState;

    if (state == ZYNetworkRestricted) {
        NSLog(@"网络权限被关闭");
    }
}

另外还实现了自动提醒用户打开权限,如果你需要,请打开

[ZYNetworkAccessibity setAlertEnable:YES];
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.