On IOS, I am using the delegate method:\
func routingService(routingService: SKRoutingService!, didChangeCurrentAdvice currentAdvice: SKRouteAdvice!, isLastAdvice: Bool) {
print("adviceInstruction")
print(currentAdvice.adviceInstruction)
delegate?.didChangeCurrentAdvice(currentAdvice.adviceInstruction)
}
The currentAdvice.adviceInstruction when running in simulator mode, returns strange instructions when it lists distances, like:
in 200 50 yards turn right
I want to be able to state in my app, where you are turning and in how far. So I would expected something like in 50 yard turn right. Is there another way of doing this?
See this article for context.
If you want "human readable" text instructions, use the TTS option for audio advices: http://developer.skobbler.com/getting-started/ios#sec24
Related
I'm stumped, iOS 11.4 ( 15F79 ), iPhone 6. Cannot get the App to Ask for Motion Data. info.plist has been set via the editor and double checked via the info.plist open in textWrangler, Also deleted key and saved via textWrangler.
<key>NSMotionUsageDescription</key>
<string>This app needs your Phones motion manager to update when the phone is tilted. Please allow this App to use your phones tilt devices</string>
I have deleted then reinstalled the app about 10 times. I have restared the phone 5 times. I have checked through settings and my app does NOT show up in Privacy-Motion and Fitness or anywhere else in settings. I am using a free developer account, maybe that has something to do with it?
I created a new Xcode game template and changed nothing apart from importing CoreMotion and this code
**** Edited, sorry I forgot to say I had started the instance, just forgot to put it here, just in case someone thinks that's the problem ************
let motionManager = CMMotionManager()
override func didMove(to view: SKView) {
motionManager.startDeviceMotionUpdates()
if motionManager.isDeviceMotionActive == true {
motionManager.accelerometerUpdateInterval = 0.2
motionManager.startAccelerometerUpdates(to: OperationQueue.current!, withHandler: {
(accelerometerData: CMAccelerometerData!, error: NSError!) in
let acceleration = accelerometerData.acceleration
print(accelerometerData)
} as! CMAccelerometerHandler)
}else{
print(CMMotionActivityManager.authorizationStatus().rawValue)
}
which prints a 0 ( an Enum - case not determined ) to the console.
In my actual app it was a 3 ( same Enum - case Denied ).
As I've said, I have uninstalled, reinstalled, edited plist via Xcode and text wrangler ( a code editor ) , tried different versions of the code above, tried the code in different places ( in did move to view, in class )tried code off apple docs. etc.... I haven't been asked the NSUsage question and the App keeps crashing.
I have looked for ways to get the Alert fired up, As in CLLocationManager.requestWhenInUseAuthorization() but I cannot find a comparable CMMotion version ( I don't think there is one. ) I have created a new swift file , imported Foundation and CMMotion and just put that code there, But still no Alert asking for Motion Data.
I tried a single view app template instead of a game template thinking that might be the issue, Nope.
What do I do?
Any help Appreciated. Thanks
You are confusing two related but different classes.
CMMotionManager gives access to accelerometer, magnetometer and gyroscope data. It does not require any user permission as this information is not considered privacy related.
In your else clause you are checking the authorisation status of CMMotionActivityManager. This object reports the device motion type (walking, running, driving). This information is considered privacy related and when you create an instance of this class and request data from it, the permissions alert is displayed.
The reason your else is being triggered is because you are checking isDeviceMotionActive; this will be false until you call startDeviceMotionUpdates, which you never do. Even if you used isAccelerometerActive you would have a problem because you call startAccelerometerUpdates in the if clause which will never be reached.
You probably meant to check isAccelerometerAvailable. If this returns false then there isn't much you can do; the device doesn't have an accelerometer.
Update
It doesn't make sense to check isDeviceMotionActive immediately after calling startDeviceMotion:
You know it's active; you just started it
I imagine the start up takes some time, so you could expect to get false if you check immediately.
Apple recommends that you do not have more than one observer in place for each motion device type, so the purpose of check the is...Active to ensure you don't call start... again if you have already done so.
If you only want gyroscope data then you don't need to call startDeviceMotionUpdates at all.
Ive been trying for a few days now to set a pin high (Estimote location beacon) from an app I'm building.
Im doing something wrong as i am getting an error when the block fires off. Error is: [ESTTelemetryInfo portsData]: unrecognized selector sent to instance...
Ive looked everywhere for a snippet but can't find anything. I only want to be able to set the pin high (i don't need to send any data). If i can set the pin high i figure i could set it low when done using the same methods. This is the code:
let telem = ESTTelemetryInfo.init(shortIdentifier: "xxxxxxxxxxxxxxxx")!
let setPinHigh = ESTTelemetryNotificationGPIO.init(notificationBlock: { (telemInfo) in
if telInfo.shortIdentifier! != "xxxxxxxxxxxxxxxx" { return }
telemInfo.portsData.setPort(.port0, value: .high)
})
setPinHigh.fireNotificationBlock(with: telem)
Any help would be greatly appreciated.
ps Sorry if this is incorrectly formatted (long time reader first time poster).
Cheers
Gary
Fixed..we'll sort of. For anyone wanting to know the right way to to set a pin high, in output mode, is to connect to the beacon first through the device manager: ESTDeviceManager() -set the delegate in the class as ESTDeviceManagerDelegate - startDeviceDiscovery(with: deviceFilter) then in the delegate method:
func estDeviceConnectDidSucceed(_ device: ESTDeviceConnectable) { self.settings.gpio.portsData.setPort(.port0, value: .high)
}
BUT -> at the moment there is a bug that portsData has no member 'setPort'. I've filed a bug issue with Estimote on GitHub. Will come back to report once it's fixed.
How many maximum printings can UIPrintInteractionController (Swift) execute?
I'm currently doing AirPrint for a project.
Wondering how to do stress tests of printing in bulk in use of Printer Simulator.
Is there a delegate of something like printInteractionControllerIsPrintingJob?
How to debug a number of printing waiting in queue?
Is there any way to customise the alert view of printing?
Cheers,
From the documentation :
1- var printingItems: [Any]? { get set }
Takes an array of printing-ready objects ( NSURL, NSData, UIImage, or ALAsset). The documentation doesn't cite any limit so we assume the limit would be the value of unsigned int in your architecture.
2- There are 2 delegate methods for the beginning and end of printing :
Start and End of a Print Job
func printInteractionControllerWillStartJob(UIPrintInteractionController)
//Tells the delegate that the print job is about to start.
func printInteractionControllerDidFinishJob(UIPrintInteractionController)
//Tells the delegate that the print job has ended.
You can use those to get the IsPrinting status. (between first and second).
3- The documentation doesn't offer any delegate method to get the waiting in queue
4- You can customise the alert using :
printInfo UIPrintInfo: The aforementioned print job configuration.
printPaper UIPrintPaper: A simple type that describes the physical and printable size of a paper type; except for specialized applications, this will be handled for you by UIKit.
showsNumberOfCopies Bool: When true, lets the user choose the number of copies.
showsPageRange Bool: When true, lets the user choose a sub-range from the printed material. This only makes sense with multi-page content—it’s turned off by default for images.
showsPaperSelectionForLoadedPapers Bool: When this is true and the selected printer has multiple paper options, the UI will let the user choose which paper to print on.
For some detailed explanation about printing using Swift, please refer to the following link:
UIPrintInteractionController - Written by Nate Cook
If this response was helpful and has what you needed, please don't forget to validate it :).
Good luck with your app.
I'm trying to wrangle the new photo features of iOS 8's photo editing capabilities. Their documentation is very sparse so I'd love some input from you as to what might be going on.
I am trying to fetch ALL the images the user has saved. I am doing a fetch but it keeps telling me the result size is 0. It also shoots out a weird error along with it
func initController()
{
_userAlbums = PHCollectionList.fetchTopLevelUserCollectionsWithOptions(nil)//GET PERMISSION BEFORE DOING THIS
println("Albums count is \(_userAlbums.count)") //error when printing this
}
This prints out
2014-10-27 17:43:50.254 appiOS[4854:732084] [PLLogging] ***** Error: logging directory does not exist
/var/mobile/Library/Logs/CrashReporter/DiagnosticLogs/
Albums count is 0
There are at least 100 images on the iPad I am using. Any idea what I am doing wrong?
Update:
Using
_userAlbums = PHAsset.fetchAssetsWithOptions(nil)
Works
There are at least 100 images on the iPad I am using. Any idea what I am doing wrong?
You are not doing anything wrong. Your expectations seem a bit out of whack, though. The statement "there are at least 100 images" seems indicative of a deeper misconception, because, after all, PHCollectionList.fetchTopLevelUserCollectionsWithOptions has nothing to do with images. It has to do with, uh, top level user collections. Evidently your device doesn't have any of those.
But now go to the Photos app on your iPad and make a few albums. Those are top level user collections! So then run your app again. Assuming you've been granted permission to access the photo library, now your logging will result in a number larger than 0.
I have started developing html applications for mutliple platforms. I recently heard about Cordova 2.0(PhoneGap) and ever since I have been curious to know how the bridge works.
After lot of code walking, i saw that the Exec.js is the code where call from JS -> Native happens
execXhr = execXhr || new XMLHttpRequest();
// Changeing this to a GET will make the XHR reach the URIProtocol on 4.2.
// For some reason it still doesn't work though...
execXhr.open('HEAD', "file:///!gap_exec", true);
execXhr.setRequestHeader('vc', cordova.iOSVCAddr);
if (shouldBundleCommandJson()) {
execXhr.setRequestHeader('cmds', nativecomm());
}
execXhr.send(null);
} else {
execIframe = execIframe || createExecIframe();
execIframe.src = "gap://ready";
But want to understand how that works, what is the concept here, what does file:///!gap_exec or gap://ready do? and how does the call propgate to the lower layers (native code layers)
thanks a bunch in advance.
The trick is easy:
There is a webview. This displays your app. The webview will handle all navigation events.
If the browser navigates to:
file:///!gap_exec
or
gap://
the webview will cancel the navigation. Everything behind these strings is re-used as an identifier, to get the concrete plugin/plugin-method and parameter:
pseudo-url example:
gap://echoplugin/echothistext?Hello World
This will cause phonegap to look for an echoplugin and call the echothistext method to send the text "Hello World" to the (native) plugin.
update
The way back from native to javascript is (or may be) loading a javascript: url into the webview.
The concrete implementation is a little bit more complex, because the javascript has to send a callback-id to native code. There could be more than one native call are running at the same time. But in fact this is no magic at all. Just a number to get the correct JSON to the right javascript-callback.
There are different ways to communicate between the platform and javascript. For Android there are three or four different bridges.
I am trying to figure this out in more detail, too. Basically there are 2 Methods on the iOS side that can help ...
- webView:shouldStartLoadWithRequest:navigationType: and
- stringByEvaluatingJavaScriptFromString:script
From the sources it seems cordova sends a "READY" message using webView:shouldStartLoadWithRequest:... and then picks up results with the second message, but I am not sure.
Cordova Sources iOSExec
There is much to learn there.