centralManagerDidUpdateState always return PoweredOff - objective-c

In my app I check if bluetooth is turn on, if is turn off I show alert to the user in order to enable it. For this functionality I using centralManagerDidUpdateState and check [central state]. On iOs 10 device works fine, but, on iOs 11 doesn't work, always return CBCentralManagerStatePoweredOff after do this:
1.- I go to configuration and I turn off the bluetooth.
2.- I open the app, the centralManagerDidUpdateState call back is called and PoweredOff is detect.
3.- I go to configuration and I turn on the bluetooth.
4.- I back to the app, and centralManagerDidUpdateState is called and PoweredOff is still the state when the bluetooth is On.
Is this issue an iOs 11 bug?, anyone knows any solution for check the bluetooth is turn on?
Thanks

I also faced with the same issue. I was testing BLE functionality by using this sample project "https://github.com/jasonmgeorge/BLEScanner" one device on iOS 10.3.3 and another on iOS 11.2. On iOS 10.3.3 it was working fine but on the other device, I was getting the same error all the time. Then I realized that
NSBluetoothPeripheralUsageDescription
wasn't in Info.plist, so I added. Again I got "CBCentralManagerStatePoweredOff". I went to settings to power off Bluetooth and on again. It's working magically. It's a iOS 11 bug most probably. Please check your implementation. It's not very consistent but sometimes it works.

Related

Mac App crashes when I add a Distribution Profile

I've created a Mac App for Mavericks that uses MapKit. It works fine during development and testing on Xcode 5.1. Now I'd like to submit it to the App Store and I need a Distribution Profile which I've created successfully. Trouble is, as soon as I add it to my project, the app doesn't run anymore - it crashes every time without fail with this error message:
When I change back to "no provisioning profile", or to the profile that Xcode created during development, the app runs again.
My question: Is this expected behaviour, or will the app be rejected by the review team? I know that iOS apps don't run with their distribution profiles, but I'm new to Mac Development. Any insights into this way too complex topic are appreciated!
My app was approved - and the crash was indeed no issue for the app review team.
I had a chat with Apple about this who were kind enough to call me back and explain the issue. Looks like this phenomenon is "kind of" expected behaviour: Mac Apps may or may not crash when run with a Distribution Profile.
To avoid this problem, we can add both a Development AND a Distribution Profile to our app, without one having to replace the other. This was news to me. Had I however opened my tired eyes a bit wider I would have perhaps spotted the little disclosure triangle myself:
Perhaps this helps those with the same issue.

App Wireless Distribution not working in iOS7. Internet Connection needed?

In iOS6 I used to install some of my apps over an adhoc network without internet sharing. So the iPad had no internet connection. Therefore I use a typical html and plist file. Everything was alright.
Now, in iOS7 the installation is not working anymore. It is just stuck in "Waiting" and nothing more happens. (Note: It is still working on my iOS6 iPad)
First I thought something might be wrong with my plist, but then I copied the files to my IIS Server and installed it from there. Here I had a internet connection on my iPad and everything worked out.
Is it possible that the wireless distribution now needs an internet connection in iOS7 e.g. to check the ipa in the app store or something like that? Because this is the only difference I can see.
The app is signed with a valid distribution profile.
Thanks for your help.
It turned out the installation of apps over the air in iOS 7 really needs an internet connection now. The iPad tries to contact at least the following URLs before installing the app.
ax.init.itunes.apple.com: The device obtains the current file-size limit for downloading apps over the cellular network.
ocsp.apple.com: The device contacts this site to check the status of the distribution certificate used to sign the provisioning profile.
It seems in iOS6 it was ok if those URLs were not reachable and now in iOS 7 they have to be reachable.
Well i just had the same problem and I figured it out. At least on my xcode this is what happened. Turns out the application target release code siging identities auto set to developer and not their current state, from xcode 4.x, which is distribution. So when I went to distribute my application I kept getting the same error you had. So Click on your project name in your project explorer then click on the application target, not the project, and make sure the code signing identity is not set to developer for your releases. I have no idea why the code signing identities were automatically set to the developer profile, maybe there was some sort of bug when updating from xcdoe 4.x to xcode 5 that caused this. But now other devices are able to install the program. Hope this helps.

iOS6: iPhone app getting restarted on receiving any type of notification in device

While testing our iPhone app in devices with iOS 6 beta 4, we found an issue wherein if any notification like reminder alert is received or when we pull down the notification curtain, the application is restarting from beginning.
It never used to happen like this till iOS 5.X. Apple release notes or known issues of iOS 6 beta did not mention anything regarding this.
Did anyone faced this issue?
Any comments on whats going wrong?
Check in the app's .plist file to see if application somehow got set not to run in the background.

iPad didn't call didRegisterForRemoteNotificationsWithDeviceToken

I'm trying to get device token in iPad for remote push notifications;
registerForRemoteNotificationTypes is called okay, no error, but didRegisterForRemoteNotificationsWithDeviceToken also not been called;
Application is appear in Settings/Notification;
What's I doing wrong?
iPhone is registering successfully.
Thank you
PS: iPad 1, iOs 5.1
In this case, if the code works on iPhone that code should work on iPad as well. Coz the os is same. Anyway if your code is not working on iPad try to remove provisioning profile from the iPad and reinstall the correct one. Sometime the old provisioning profile remains. And don't forget to check the code signing on target as well.
check that you are registering correctly for Push Notifications, including verifying your provisioning profile for "aps-environment" key and the code signing of the .app.
also you can debug Push Notification status messages in the console (you will need to install PersistentConnectionLogging.mobileconfig provisioning profile on your device and reboot it. check out this link under "Observing Push Status Messages").
There is an important thing to know with the provisioning profile. You should ensure to create the certificate first (the one used for the notifications), and then recreate the provisioning profiles, so that they know about the notifications. So you're sure it's not a provisioning profile issue.
Well, problem was solved in production sign and provisioning, but not in development. When I archive application for device and load it through iTunes, push notifications is working. Very strange behaviour.
I know it's a late answer, but it may help others. I had the same issue as the OP. After you click ok on the notification popup, it disappears but none of the method gets called to get the device token. Then I checked the internet connection when testing push notifications and I realized I had no connection. After re-connecting, it began working fine.

iPhone Simulator - set HTTP proxy

I'm coding an iPhone app that needs to make small HTTP requests to the Internet. Within our corp LAN, all HTTP traffic has to go through Squid.
The simulator is clearly capable of using a proxy - since Mobile Safari works. But, how do I get/set the proxy settings in code?
A bunch of the headers are commented out for the simulator. For example,
CFNetworkCopySystemProxySettings
In CFProxySupport.h is not available to the simulator - only to the device. I've tried hardcoding like this:
CFReadStreamSetProperty(stream, kCFProxyHostNameKey, #"internal.proxy.servername");
CFReadStreamSetProperty(stream, kCFProxyPortNumberKey, [NSNumber numberWithInt:80]);
CFReadStreamSetProperty(stream, kCFProxyTypeKey, kCFProxyTypeHTTP);
But no joy.
Thoughts?
You can try:
"System Preferences" -> "Network" -> Select your network device -> "Advanced" -> "Proxies"
You can try using Proxifier: http://www.proxifier.com/mac/
It enables you to set a proxy to any program.
Not what you asked but it should solve your problem.
To close this off. It looks like this is fixed in iOS4 SDK - the network stack on the simulator will use the Mac's proxy for any HTTP calls.
Looks like XCode 4.0 (4A304a) has broke this again. If I set the stack to proxy http calls through Burp, works fine with every app (Safari, etc) but the simulator.
Simply restart the iPhone simulator.
for this i use the following trick
go to setting >> General >> Accessibility >> bold text to switch on >> picker view open and ask for restart for make it effective >> press continue >> iPhone simulator now restart
the pop-up ask for user name and password for proxy...
tested in ios simulator 7.1
This question is a bit old, but thought I would add my findings for reference. In the iOS 4.x SDK at least, the following code works on both the simulator and the iPhone.
CFDictionaryRef systemProxyDict = CFNetworkCopySystemProxySettings();
CFReadStreamSetProperty(m_resultRef, kCFStreamPropertyHTTPProxy, systemProxyDict);
The simulator is probably not capable of using a proxy. It is using the standard networking stack provided by Mac OS X, and that is what is using the proxy.
If the constants are commented out during simulator use, and you've tried hard-coding it with no luck, then this is probably one of the many things that is simply not the same between the simulator and a device, and you'll have to test this part of your application on a device.
Just close and reopen simulator after applying configuration.