Giter Site home page Giter Site logo

zynetworkaccessibity's Introduction

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];

zynetworkaccessibity's People

Contributors

ziezheng avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.