简体   繁体   中英

How to pop-up the "Cellular data is Turned Off" warning message?

Apple's built-in applications show a pop-up message whenever the user doesn't have cellular or wifi connectivity. It looks something like:

"Cellular data is Turned Off

Turn on cellular data or use Wi-Fi to access data

[Settings] [OK]"

Clicking on the Settings button opens the settings panel.

Is this a system pop-up? How can I use it in my own application?

I'm already using UIRequiresPersistentWiFi but it uses a different type of message which appears when airplane mode is on.

Thanks!

You need to enable Application uses Wi-Fi in info.plist. Then this warning is displayed when cellular data is turned off and you're not connected to wi-fi.

Look at the Reachability example in Apple's Sample code. It will give you all the code you need to determine if you're connected or not to the internet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM