I use Estimote indoor location example to make the location list. But the location list is null. I think the problem that is the App can't find my estimote cloud. Please tell me how to solve the problem.
Code:
weak var weakSelf:ListViewController? = self
let onSuccess:(AnyObject!) -> (Void) =
{ (locations:AnyObject!) in
weakSelf!.ownLocationsArray = locations as! NSMutableArray
weakSelf!.tableView.reloadData()
weakSelf!.hadError = false;
self.finishedSectionRefresh()
}
self.manager.fetchUserLocationsWithSuccess(onSuccess, failure: onFailure)
In order for the app to "find" your Estimote Cloud account, you need to use ESTConfig's setupAppID:andAppToken: method. You can generate the token on:
https://cloud.estimote.com/#/apps/add/your-own-app
Since you're writing in Swift, you might have to add #import <EstimoteSDK/EstimoteSDK.h> to your Objective-C Bridging Header, so that your app gains access to the ESTConfig class.
Related
I am currently working with the Inspire 2 & the M210 RTK. Can anyone help me in getting the Obstacle Avoidance sensor data output from the drone using the Mobile-SDK? I would like to get the exact distance reading from the object in front of the drone in an constantly updating value. Any code examples? I am relatively new to the DJI SDK so any help would be greatly appreciated. Thanks in advance!
Before getting into this, keep in mind that the distance you receive is not perfectly accurate.
There is a few ways you can access the sensors with the mobile SDK.
1/ Traditional interfaces using the obstacle avoidance part of the DJIFlightAssistant
Implement the delegate DJIFlightAssistantDelegate
Implement the didUpdateVisionDetectionState method
In the DJIVisionDetectionState object, there is a detectionSectors property which is an array of DJIObstacleDetectionSector which have a obstacleDistanceInMeters.
2/ Using the keys, you can start listening to the Flight Controller key DJIFlightAssistantParamDetectionSectors. The block called will contain an array of DJIObstacleDetectionSector which have a obstacleDistanceInMeters:
guard let detectionSectorsKey = DJIFlightControllerKey(param: DJIFlightAssistantParamDetectionSectors) else {
// failed to create the key
return;
}
guard let keyManager = DJISDKManager.keyManager()? else {
// failed to access the keyManager. You're most likely not registered yet.
return;
}
keyManager.startListeningForChanges(on: detectionSectorsKey, withListener: self, andUpdate: { (oldValue, newValue) in
let sectors = newValue?.value as! [DJIObstacleDetectionSector]
//do stuff.
})
Good morning SO!
I am currently working on an iOS app that requires me to use Google Maps' reverse geocoding features. The tricky part is that I need to be able to access the full list of address components (i.e. the full "address_components" value from the JSON returned from this example, including short and long names)
When using the Google Maps iOS SDK, it seems that all results from reverse geocoding are given in the form of GMSAddress, which only exposes a small subset of these values (and no short versions). I have so far not found a way to access what I need.
Is there any way to get these values through the iOS SDK? If not, is it okay to try and call the google maps API directly? Has anybody tried?
Thank you for your time,
Julien P.
I am working on one such app...I don't know about iOS SDK.
But, Google API will help for this. This tutorial here gets the address of a location you click on:
https://www.raywenderlich.com/109888/google-maps-ios-sdk-tutorial
You will not be able to call Google API directly. You will need to add a server for this. This tutorial gives a detailed and clear way to do this.
Hope this helps. All the best
I found an easy solution using the LMGeocoder library for iOS.
Inside LMAddress, there is a lines attribute that will contain all the information. You can access it easily with the following piece of code.
func getAddressComponent(name: String, lines: [[NSObject: AnyObject?]]) -> (short: String?, long: String?)? {
let filteredLines = lines.filter { ($0["types"] as! [String]).contains(name)
guard let line = filteredLines.first else {
return nil
}
let longName = line["long_name"] as? String
let shortName = line["short_name"] as? String
return (short: shortName, long: longName)
}
This is using Swift 2.3 but will probably work for Swift 3 as well. Hope it helps anyone! :)
Julien
I'm building an app that uses geofencing but I realised that CLRegion has many limitations, for example:
that location authorizationStatus must be .authorizedAlways in order for region monitoring to work.
only circular regions can be monitored
This limits the functionality that can be applied using region monitoring. However after doing some research i found out that there are ways to change this behaviour by creating a custom class of CLRegion.
To be honest I have no idea how to do this or where to start. Does anyone have any suggestions as to how such a custom CLRegion class could allow customised geo-fencing?
There is a tutorial on appcoda that talked about this briefly, but it wasn't in depth at all, you can find it here:
https://www.appcoda.com/geo-targeting-ios/
There they suggest starting with protocols such as:
protocol RegionProtocol {
var coordinate: CLLocation {get}
var radius: CLLocationDistance {get}
var identifier: String {get}
func updateRegion()
}
protocol RegionDelegateProtocol {
func didEnterRegion()
func didExitRegion()
}
And from these one can create custom functionality for CLRegions, such as monitoring polygons etc.
How should one get started on implementing custom regions?
Thanks!
I'm a relatively new swift developer and I've heard in iOS 8 you can send local notifications based on a users Location. I have had a look at some code, particularly this one to create simple time based local notifications.
var leftNotification1:UILocalNotification = UILocalNotification()
leftNotification1.alertBody = "NotidicationA"
leftNotification1.repeatInterval = NSCalendarUnit.CalendarUnitHour
leftNotification1.fireDate = NSDate(timeIntervalSinceNow: 900)
UIApplication.sharedApplication().scheduleLocalNotification(leftNotification1)
I have also seen that you can replace fireDate with a location trigger like something like this:
var localNotification:UILocalNotification = UILocalNotification()
localNotification.regionTriggersOnce = true
localNotification.region = CLCircularRegion(circularRegionWithCenter: CLLocationCoordinate2D(latitude: 37.33233141, longitude: -122.03121860), radius: 50.0, identifier: "Location1")
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
I know with locations you need permission from the user and poll for locations and that. I am not aware of how to do that sort of thing and link it with that code. When I just enter this code into my ViewDidLoad like I do for the top one it doesn't work for obvious reasons, the CoreLocation isn't registered and its not polling for locations. If someone could inform me about how to get this code working or even better give me an example code to take a look at that'll be great. Thanks.
I found a few guides that had different ways of approaching this, you need to import CoreLocation then you'll want to register the CLLocationManagerDelegate in the ViewController function in ViewController.swift.
You'll need to get permission for using the location with
locationManager.delegate = self
locationManager.requestAlwaysAuthorization()
UIApplication.sharedApplication().cancelAllLocalNotifications()
If you use the requestWhenInUseAuthorization instead it won't display the notifications as they only are displayed when you are not in the app. In iOS 8 it requires you to declare NSLocationAlwaysUsageDescription in the info.plist file you'll just enter some text to appear when location access is requested.
Once you've done all of that you can start creating your notifications, you can use the following code to do that
let locattionnotification = UILocalNotification()
locattionnotification.alertBody = "You have entered a high risk zone (Crown Range Road) , proceed with caution"
locattionnotification.regionTriggersOnce = false
locattionnotification.region = CLCircularRegion(circularRegionWithCenter: CLLocationCoordinate2D(latitude:
37.33182, longitude: -122.03118), radius: 100.0, identifier: "Location1")
UIApplication.sharedApplication().scheduleLocalNotification(locattionnotification)
The regionTriggersOnce option allows you to turn on and off if you get multiple messages when you enter and exit the zone or only one when you first enter the area.
You can change the latitude, longitude and radius (in meters) values to what you want and when you get within the radius of the point you will be alerted with the contents of the message.
For more details about the different options have a look at https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/
The SetSDK allows you to set this up really really simply now. Basically, just a few lines of code.
SetSDK.instance.onDeparture(from: .any) { departed in
/* do your Swift things here */
let departureCoordinates = departed.location
// keep going
}
SetSDK.instance.onArrival(to: .any) { arrived in
/* do your Swift things here */
let arrivalCoordinates = arrived.location
// keep going
}
The SDK handles doing the persistent location collection without killing your battery and the locations that it sends notifications for are continuously being learned, so no manual entry of geofences or anything like that. Just start it and go.
So I am trying to get CLFloor in Core Location to give me data instead of returning nil in Swift, but I have not been able to. I have tried my own code and the following from NSHipster:
import CoreLocation
class LocationManagerDelegate: NSObject, CLLocationManagerDelegate {
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: AnyObject[]!) {
let location: CLLocation? = locations[0] as? CLLocation
if let floor: CLFloor? = location?.floor {
println("Current Floor: \(floor?.level)")
}
}
}
let manager = CLLocationManager()
manager.delegate = LocationManagerDelegate()
manager.startUpdatingLocation()
Does anybody know how to make this work on a device or in the simulator, I'm sure the answer would benefit a lot of people. If anyone knows of any good resources on this or CLVisit, that would also be helpful.
As far as I understand what was said in WWDC session 708 - Taking Core Location Indoors, You need to manually register and set up the particular venue on the new Apple's Maps Connect page in order to get the floor information in iOS.
Therefore, it seems there is no way that the floor info is provided automatically (e.g. based altitude information from on GPS) for an arbitrary venue.
based on these 2 links from Apple's website
CLFloor Ref
CLLoaction Class Ref
Discussion
If floor information is not available for the current location, the value of this property is nil.
I'm not expert in swift but i think
returns nil possibly means that there is no floor information at that location.
I don't think iOS will magically tell you the floor level from what I understand https://developer.apple.com/videos/wwdc/2014/?id=708. You need to somehow get that number in another way. E.g. you may capture some iBeacon signal and from that download the floor level number, or swipe on your screen to find the correct floor map you are on?