Reputation: 19
I want to activate mobile data from my application developed with react native. I want to insert two buttons one to enable and the other to disable. I've been everywhere and only the connection status is presented to me, whereas my case is just to open and close the mobile data (internet connection).
Upvotes: 0
Views: 611
Reputation: 6792
With React Native, you'd have to use Native Modules it looks like.
But with that said, for Android, it looks like Google removed the ability to toggle mobile data from an app in Java in general; so you may not have an option at all - unless you're only targeting rooted phones. See this article for details.
For iOS, your outlook isn't great either...
So, you may want to think of a different approach, like checking to see if it is enabled, and if not, recommending the user enable it via a toast message or popup.
I couldn't find any already built native modules for React Native for checking the mobile data state, but it doesn't mean they don't exist. But hopefully this helps point you in the right direction in any case.
Upvotes: 1