Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

isAirplaneEnabled always return true #37

Closed
DCKT opened this issue Jun 1, 2018 · 9 comments
Closed

isAirplaneEnabled always return true #37

DCKT opened this issue Jun 1, 2018 · 9 comments

Comments

@DCKT
Copy link

DCKT commented Jun 1, 2018

Hello,

On iOS only , isAirplaneEnabled() always return true.
It works perfectly on Android. Maybe a config issue ?

Thanks 馃槃

@c19354837
Copy link
Owner

Have you run the example ?

It works fine in my iPhone 7 plus (iOS 11.3.1), how about your test device?

@DCKT
Copy link
Author

DCKT commented Jun 4, 2018

Hi @c19354837

I does compile on the simulator but not on my test device, I have this error :
capture d ecran 2018-06-04 a 10 47 11

EDIT : I'm on the latest XCode version I think (9.3.1) & my test device is an iPhone 5C (iOS 10.3.3)

@c19354837
Copy link
Owner

Some APIs may not work well in simulator, and you should test in the physical device.

The error is React-Native's bug, see this PR

I just change the code to:

static NSString *RCTCacheKeyForImage(NSString *imageTag, CGSize size, CGFloat scale,
                                     RCTResizeMode resizeMode, NSString *responseDate)
{
    return [NSString stringWithFormat:@"%@|%g|%g|%g|%lld|%@",
            imageTag, size.width, size.height, scale, (long long)resizeMode, responseDate];
}

@DCKT
Copy link
Author

DCKT commented Jun 5, 2018

Yes I succeeded to make it compile and I have the same behavior : here is a screenshot

img_0013

As you can see, the airplane mode is not enabled and it says it's "On". Is it normal, when I want to toggle the switch it send me to the bluetooth settings ?

@c19354837
Copy link
Owner

It's really strange.

I'll try to find a iPhone with iOS 10. It may take some time.

For some iOS's limits, this lib just opens the Settings app whit the last page that you open.

@DCKT
Copy link
Author

DCKT commented Jun 5, 2018

Thanks for your quick answers 馃槃

@c19354837
Copy link
Owner

I think I get it.

I get airplane's status by:

NSString * radio = [[CTTelephonyNetworkInfo alloc] init].currentRadioAccessTechnology;
bool isEnabled = radio == nil;

and the currentRadioAccessTechnology means The current radio access technology the device is registered with.

Normally, if your device has no SIM, isAirplaneEnabled() always return true.

There is no official API which can get airplane mode directly.

Here are some discussions.


And

Is it normal, when I want to toggle the switch it send me to the bluetooth settings ?

It's a bug in iOS 10, and it's normal in iOS 11 for some system limits. Next version will fix it.

@DCKT
Copy link
Author

DCKT commented Jun 11, 2018

Hi @c19354837

Thanks a lot for your investigations ! I will find a device with a SIM card.
I think you can add this to the README 馃槃

@DCKT DCKT closed this as completed Jun 11, 2018
@c19354837
Copy link
Owner

V1.4.6 is available.

fix bug: switchAirplane() will open Bluetooth Setting Page for iOS.

Also I update the README & API.

Thanks for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants