Send data to server whenever internet connection is available iOS

五迷三道 提交于 2019-12-05 14:28:24

Try this Apple example: https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html

If you want this to work when app in background try background task

If you what your app doesn't suspend in background look at this: http://www.raywenderlich.com/29948/backgrounding-for-ios

You may check Internet connectivity via Reachability class while your app is running in foreground or background state.

But if your app is closed then you can't detect network connection within your app. So its not possible to generate any notification by detecting network connection while app is closed.

Apple write an demo for this.Just search reachability in Xcode Document and APIs(or in iOS developer library).And choose sample code.

I'm afraid you must use background task.Look up background task guide.But I think it's a little abuse for just check network.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!