Apple AirLocation demo App ranging not shows beacons - ibeacon

I have3 Estimote beacons that can be seen with the App store Estimate App.
Now I am trying to run the Apple demo app AirLocation AirLocate
I have changed the UUID in the APLDefaults.m file to the default Estimote UUID _supportedProximityUUIDs = #[[[NSUUID alloc] initWithUUIDString:#"B9407F30-F5F8-466E-AFF9-25556B57FE6D"]];
I have enabled the Region to start startMonitoringForRegion as this stackoverflow says.
But they are not showing up, have you seen this ? Or am I missing some Estimate specific.
Regards

The problem is that AirLocate was written for iOS7, and in iOS8, the permissions model for iBeacons and other location operations has changed. In order to get the program to work on iOS 8 when compiled from XCode 6, you need to add code that requests permission in your AppDelegate. Like this:
if([self.locationManager respondsToSelector:#selector(requestAlwaysAuthorization)]) {
[self.locationManager requestAlwaysAuthorization];
}
This will prompt the user to authorize location operations including beacons. You also need to edit the info.plist for the app, and add a new string key called NSLocationAlwaysUsageDescription with a value like "This app needs access to location services" so the OS can prompt the user for this permission.
After you run your app, you can check in settings to see if this permission has been granted properly.

Another problem I have noticed in iOS 9 is that the calibration sometimes does not work. Seems to be an NSNumber conversion issue. The following edit in APLCalibrationCalculator.m fixed it:-
//measuredPower = [[sample valueForKeyPath:#"#avg.rssi"] integerValue];
measuredPower = [[sample valueForKeyPath:#"#avg.rssi"] intValue];

Related

NSNetService says it is published, but it isn't visible on the network

I'm working on a little iOS app for my own use (initially, at least) and I thought I would use Bonjour to configure networking between two iOS devices.
My server's interface defines
NSNetService *netService;
and the implementation uses the following code to advertise its existence:
const NSString *kSEBonjourServiceDomain = #""; //use defaults
const NSString *kSEBonjourServiceName = #"_test._tcp.";
//...
netService = [[NSNetService alloc] initWithDomain:(NSString *)kSEBonjourServiceDomain type:(NSString *)kSEBonjourServiceName name:#"" port:sin.sin_port];
if (netService)
{
netService.delegate = self;
netService.includesPeerToPeer = YES;
[netService publish];
}
else NSLog(#"Failed to create NSNetService");
When I start the server, my NSNetService object does call the -netServiceDidPublish: delegate method, but when I use Discovery to browse the bonjour services on my network, my service doesn't appear. Apart from the const strings, this code is the same as some code in one of my Mac apps (which works as expected) and also very similar to Apple's sample code.
I've gone through all the options in Xcode's capabilities tab in case I needed to add something there, but I can't see anything relevant. I've also read a bunch of documents and tutorials that don't mention having to do anything more than that, but it wouldn't surprise me to learn that this only works on iOS if you set an obscure build setting to a string that you had to learn about by reading the Human Interface Guidelines for watchOS last September.
So, can anyone enlighten me? What am I missing?
Thanks in advance!
It turned out that due to a silly error elsewhere in my code, sin.sin_port was set to 0 by the time I was registering my NSNetService. Although NSNetService doesn't see this as a problem, it was causing the service to be ignored by service browsers.
So the answer is, a service with a port of 0 will register without error, but won't work.
Thanks to gaige for the assistance.

Parse FB SDK Login Application Transport Security errors on device but not on simulator XCode 7.1 Swift IOS 9 FBSDK 4.7

Although I have seen similar questions posted here, I have not been able to resolve my issue via plist settings. Any other ideas? Here is where I am:
Adding FB Login to a simple IOS app using the Parse framework
All versions are up-to-date as of today. XCode 7.1, IOS 9, Parse latest, FB SDK latest (4.7)
I have added the specified IOS 9 settings for the FB SDK in my plist. I even combined the lists to include the extra setting required for FB SDK 4.7.
The mystery:
last night I could not get this to run on my simulator, but after
re-adding the plist settings and re-importing all the libraries, I
finally got the FB login screens to show up on the iphone 6 (has been
upgraded to IOS 9). I couldn't get it to run on the simulator but i
left it at that.
now today i tried it on the iphone again and i keep getting the ATS-looking errors.
On the iphone the error is:
Cannot Verify Server Identity. The identity of "m.facebook.com" cannot be verified by Safari. Review the certificate details to continue.
In the XCode console the error is:
FBSDKLog: WARNING: FBSDK secure network request failed. Please verify you have configured your app for Application Transport Security compatibility described at https://developers.facebook.com/docs/ios/ios9
It seems to me that the plist fix is allowing the FB Login to work in my simulator, but why wouldn't it also work on the iphone? Could this have anything to do with Parse? Below is my login code:
class LoginViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate, UITextFieldDelegate {
#IBAction func FBLoginButtonPressed(sender: AnyObject) {
// Set permissions required from the facebook user account
var permissionsArray : [String]?
permissionsArray = ["user_about_me"]
var userBlock : PFUserResultBlock?
// Login PFUser using Facebook
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissionsArray, block: userBlock)
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissionsArray) {
(user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
print("User signed up and logged in through Facebook!")
} else {
print("User logged in through Facebook!")
}
self.performSegueWithIdentifier(self.tableViewSegue, sender: nil)
} else {
print("Uh oh. The user cancelled the Facebook login.")
}
if let e = error {
print(error)
}
}
print(userBlock.debugDescription)
}
picture of plist
Okay, the mystery has been solved. Parents of teens may be able to relate.
It turns out that last night when the login was working on my teen's iphone, it was set to use mobile data ON PURPOSE to bypass the content filtering settings on our network! The reason I didn't realize this today was because the FB app seemed to be working on the iphone (upon later scrutiny I see that there was just some cached content), and my mac is set to bypass the content filtering. So this is why it worked on the simulator but not on the iphone (when the iphone was set to use wifi and not mobile data).
So the FB error was a red herring. I just wasn't looking down that path...

Game Center not authenticating using Swift

I'm trying to authenticate the local player using swift, but every time I get a false value for the .authenticated property. Here is the code I'm using, it is called by the main view controller when the app starts.
func authenticateLocalPlayer(){
var localPlayer = GKLocalPlayer()
localPlayer.authenticateHandler = {(viewController, error) -> Void in
if viewController {
self.presentViewController(viewController, animated: true, completion: nil)
}else{
println((GKLocalPlayer().authenticated))
}
}
}
It brings up the log in view just fine, but when I enter a test account login, it just returns the GKLocalPlayer().authenticatedas false. The bundle identifier in iTunes Connect and the info.plist are exactly the same, as is the version and the app name. Everything is enabled for Game Center on iTunes Connect and in Xcode, but I have a feeling it's not a coding error, it's a setup error in the app record somewhere but I can't for the life of me find where.
After further tinkering, I'm getting this error:
Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognized by Game Center." UserInfo=0x17006b300 {NSLocalizedDescription=The requested operation could not be completed because this application is not recognized by Game Center.}
I have no idea why this is the case, the bundle ID, name and versions all match...
Any help would be greatly appreciated.
This issue has been resolved by Apple - just call:
GKLocalPlayer.localPlayer()
Previously, the issue was that GKLocalPlayer() does not return the GKLocalPlayer singleton, but instead returns a new GKLocalPlayer instance.
If you were on the Xcode 6 BETA, you could add a C function or Objective-C method that returns the real GKLocalPlayer singleton, then use this in Swift. This is the gist of my workaround (with bad naming conventions):
In an Objective-C header:
GKLocalPlayer *getLocalPlayer(void);
In an Objective-C implementation:
GKLocalPlayer *getLocalPlayer(void) {
return [GKLocalPlayer localPlayer];
}
In your bridging header:
#import "ThatHeader.h"
Then whenever you need to access the GKLocalPlayer singleton in Swift, you can just use getLocalPlayer() instead of GKLocalPlayer(). It's probably a better idea to stick that in an method of a GKLocalPlayer category.
However, this is no longer necessary as detailed above.
Even with Xcode 6 Beta 6, on a device using iOS 8 beta 5, making GKLocalPlayer.localPlayer() available, I was still getting the error:
"NSLocalizedDescription=The requested operation could not be completed
because this application is not recognized by Game Centre"
The solution (discovered through Apple's Dev forum) was to go to "Settings" on the device, and then into "Game Centre" and enable "Sandbox" under the developer section.
You can use that, I create a simple class for iOS game center in GitHub
Easy Class Game Center Swift
https://github.com/DaRkD0G/Easy-Game-Center-Swift

Issue in Titanium Appcelerator

I am trying to import a project and run it onto iPhone Simulator on Appcelerator, but I am getting a message on console that says,
[WARN] : The Ti.Geolocation.purpose property must be set.
[INFO] : {"source":{"cache":false},"type":"error"}
I have spent more than 2 hours on trying to eradicate the issue.
Also, Please share useful resources about appcelerator app lifecycle.
It says "The Ti.Geolocation.purpose property must be set."
I would try something like
Ti.Geolocation.purpose = "Find restaurants near you";
iOS want to let the user know why your App wants to know his location. The user must allow this Geolocation permission. Thats why you should surround your location requests with an if-statement:
if (Titanium.Geolocation.locationServicesEnabled){
Titanium.Geolocation.getCurrentPosition(function(e){
Ti.API.info(e.coords);
}
}else{
Titanium.UI.createAlertDialog({title:'Location Service', message:'Please turn on your location services.'}).show();
}
The parameters to be sent to the Call, were wrong.

xcode project always gets facebook login fail status

I encountered a facebook login problem. I installed FB SDK 3.0 and sample projects seemly run well --- not quite sure though. When I create a button in my own project and try to log in to Facebook, I always get FBSessionStateClosedLoginFailed from sessionStateChanged method, although I apparently get the page "You have already authorized this app. Press Okay to continue". I also tried log out through Simulator Safari facebook page, and re-launched my project and I got new username/password page and I then logged in, but I still get FBSessionStateClosedLoginFailed!
A few more observations.
1, I got FBSessionStateClosedLoginFailed thru NSLog, the log comes up right after I clicked Okay button on the Facebook page "You have already authorized this app.
2, I tried clean xcode project cache, but no help.
Kind of frustrated. I wonder if any of you can help on this problem. Appreciated!
-Tony
Addition:
I did a bit more research, and I found what I have is probably a typical problem, as Facebook highlight here ("Pro-tip 3: Complete all iOS App Settings" section in page http://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/). The image with a big red cross over iPhone is exactly what I have. From xcode project, I click my login button, and I'm directed to this page, and every time I have to click "Okay" on this page (let me call it Okay_page) to go back to my app in Simulator, however with login status as FBSessionStateClosedLoginFailed. I checked bundle ID, I have it correct. I don't have a 'YOUR_IPHONE_APP_STORE_ID' yet, which I believe I need pay Apple to get and I will do it later but not while I'm still working on it.
Now get a couple of questions:
1, Do I have to have YOUR_IPHONE_APP_STORE_ID to skip this Okay_page?
2, Does this (not automatically re-directed back to my app from this Okay_page) have anything to do with that I always get a login status of FBSessionStateClosedLoginFailed when I manually click Okay in this Okay_page and return to my app in Simulator? In another word, is (that I have to manually click Okay to get back to my app in Simulator) (the reason I got a status of FBSessionStateClosedLoginFailed)?
Did you have set this function in AppDelegate?
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [FBSession.activeSession handleOpenURL:url];
}
I had the same issue:
We created the facebook app (developer.facebook.com) setting our
bundle id (ex. com.MyCompany.MyApp)
Off course, created our iOS app with the same bundle id
After delivered our app to the client, he changed the bundle id
without notify us.
Obviously he started to get FBSessionStateClosedLoginFailed errors!
So, you probably have different bundle id's between your iOS project and your Facebook App.
I had this error and couldn't resolve it for quite some time. It turns out that if you are using the native iOS Facebook account in settings and choose "no" for allow Facebook for this app, the app is blocked by the OS. You will always get the FBSessionStateClosedLoginFailed error and there is nothing you can do inside the code to fix this (99% sure). The best you can do is alert the user to check out the settings.
i am typing wrong line in given below method. self.session was nil
return [self.session handleOpenURL:url];
it should be
return [[FBSession activeSession] handleOpenURL:url];
Use Following Method.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [[FBSession activeSession] handleOpenURL:url];
// return [self.session handleOpenURL:url];
}
I fixed this problem after I reset the simulator. iOS Simulator - Reset Content and Settings..., hope to help.
I had this issue because I was calling [FBSession.activeSession close] in my applicationDidEnterBackground: app delegate callback. This closed the session so that when the redirect brought the app back up to open the session, it failed because it had been put into the closed state.
Make sure that you're not closing the session anywhere before you get to the Okay page.
go to Facebook.com. Open your application on the left panel -> Status & Review -> there is a toggle with text "Do you want to make this app and all its live features available to the general public?". Turn it on
well. I followed FBLoginCustomUISample somewhere on github.com and it was a working example of facebook login implementation from facebook itself. You can also read my workaround while creating facebook login feature in a iOS app. Here is a link form me:
Native iOS Facebook SSO won't return to app

Resources