Launch Nokia HERE Maps iOS via API - iphone

Is there a documented API for launching Nokia's HERE Maps iOS app for turn-by-turn navigation ?

here-place://lat,lon e.g. here-place://48.866833,2.355411
to open Here on a given place.
here-route://lat1,lon1,name1/lat2,lon2,name2
to start turn by turn navigation from lat1,lon1 to lat2,lon2.
here-route:///lat2,lon2,name2
to start a turn by turn navigation from the user location to lat2,lon2.
EDIT: It seems that name fields now support URL percent escaping to encode space and other characters (Tested in Here WeGo v2.0.11. Thank you marcel for the head up).

Changed to here-location://lat,lon,name in the latest versions (probably 1.2 or so). name is optional.
here-place and here-route give Couldn't open link error, so probably syntax changed there. Maybe you can specify addresses there, but it was out of scope of my research.

On HERE WeGo 2.0.20 (537):
Open a URL with a custom here-route URL Scheme:
//mylocation/latitude,longitude
,URLencoded string as the name of the destination
?ref=<Referrer> referrer (and can be something like your app or company name)
&m=w to indicate the routing mode (m=w stands for walk, m=d for drive)
For instance, here-route://mylocation/37.870090,-122.268150,Downtown%20Berkeley? ref=<Referrer>&m=w requests a route by foot to a destination in downtown Berkeley by a company called Referrer.
Source: HERE Developer Mobility On-Demand Technical Solution Paper (page 36)
I've just tested this and it works fine. The most important bit (at least for me) was that /mylocation/ has to be in the URL for HERE WeGo to start navigation from the user's current location (literally the word mylocation has to be there).
You can also use here-route://sourceLat,sourceLon,sourceOptionalName/destLat,destLon,destOptionalName if you don't want to navigate from the user's current location.
I also tested here-location://lat,lon,optionalName and it works fine in the current (latest, see at the top of this answer) version of HERE WeGo (it used to be here-place, but it doesn't work anymore).

URL Scheme for an application can be found in the app's Info.plist. In Info.plist -> URL Types -> URL Schemes -> xxxxx
Extracting bundle contents from ipa is easy. Rename file from .ipa to .zip and unzip to extract contents. Right click on DownloadedApp.app and show package contents. You will find Info.plist, icons, compressed nibs, executable, etc there.
For Nokia HERE Maps app it is nok

#FKDev
Basically you can replace spaces with %20 sign. Found on NSData & NSURL - url with space having problem or Spaces in a NSURL with variables doesn't load
I preferred too use internal converters shown in the examples
Xcode sample
NSString *sUrl = #"here-route:///52.379189,4.899431,Amsterdam Central
sUrl = [sUrl stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [NSURL URLWithString:sUrl];
C# Sample
var sUrl= Uri.EscapeUriString(#"here-route:///52.379189,4.899431,Amsterdam Central");
var url = new NSUrl(sUrl);
Both sample will be here-route:///52.379189,4.899431,Amsterdam%20Central

Related

Is the clipboard officially called "pasteboard" on iOS?

I am writing an iOS app and I just want to make sure I call it the appropriate thing. I'm used to clipboard but apparently Apple calls it a pasteboard on iOS. Googling doesn't turn anything specific up.
I see the class is called UIPasteboard but I'm just looking to verify the literature/end user communication uses this term as well.
Yes, UIPasteboard is the clipboard (or the service behind the copy and paste feature). Most users are unlikely to know what either pasteboard or clipboard means. If you're describing the feature you should probably use the simple 'copy & paste' terminology.
I have the same question: which string is preferable to show to the user?
"Copy"
"Copy to Clipboard"
"Copy to Pasteboard"
Looking at the standard built-in apps on iOS 12, it looks like the first form ("Copy") is used almost everywhere.
Doing some more research, I googled for pages containing "pasteboard" on site:help.apple.com, and found pages such as https://help.apple.com/voiceover/info/guide/10.7/English.lproj/_1128.html which include text like You can also copy the last spoken phrase to the Clipboard (also called the “Pasteboard”) by pressing VO-Shift-C. But note that this is a page for macOS, not iOS. When I searched for iOS pasteboard site:help.apple.com I got zero results, while searching for iOS clipboard site:help.apple.com got many hits, all of which suggests that Apple doesn't use the term "pasteboard" when addressing users (even though UIPasteboard is the name of the internal API).
Another data point is that the Simulator has a menu command Edit / Automatically Sync Pasteboard although (speculation!) maybe that's meant to be understood by developers not end-users?
I've got a similar problem in that I'm trying to display an error message if the pasteboard contents are "invalid" in the current situation. (In the app, there is a main tweet which has already been loaded in the main part of the window, but I also want to let the user select a second tweet if they've copied a Twitter URL to the pasteboard.) I want to say something like The tweet on the pasteboard could not be downloaded but I assume most users won't know what a "pasteboard" is, and even changing it to The tweet on the clipboard could not be downloaded isn't great IMHO. Removing the on the pasteboard/clipboard phrase is not an option because The tweet could not be downloaded won't work since it sounds like it applies to the main tweet already loaded in the main part of the window, not the tweet on the pasteboard. I could remove the message entirely, but then the user wouldn't know if they successfully copied an invalid link to the pasteboard; they could keep retrying because they think the copy-to-pasteboard failed, not the download-from-twitter failed.
Update 2019-07-20: I wanted to document how Google Chrome does it, because it seems like a good solution. When you tap into the search box to start typing a URL, it provides an extra option immediately below it saying "Link You Copied" followed by the link. I like this because "You Copied" aligns with the action the user took ("Copy") and avoids the whole issue of using "pasteboard" or "clipboard".
from ios development cookbook :
Pasteboards, also known as clipboards on some systems, provide a
central OS feature for sharing data across applications. Users can
copy data to the pasteboard in one application, switch tasks, and then
paste that data into another application. Cut/copy/paste features are
similar to those found in most operating systems. Users can also copy
and paste within a single application, when switching between text
fields or views.
so to answer your question yes, clipboard is called pasteboard in iOS.
Looking at the human interface guidelines, there is a picture of app showing a pop up menu with an option for Copy. So simply say Copy and do not mention pasteboard or clipboard
https://developer.apple.com/ios/human-interface-guidelines/interaction/3d-touch/

openURL a local file or force UIDocumentInteractionController to use a specific app

I wish to open a file (stored locally in my app) with another app.
Currently, I am using openURL (there is a dedicated url scheme), and it works fine if I use a file hosted on the internet, but I would like to use a local file so:
a) it works offline
b) a lot of the time my users are either out of cell zone coverage, or roaming internationally
What I have tried so far:
I have not had any luck telling openURL to use a local file, I have tried a few approaches but they are all something like this
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"test" ofType:#"ext"];
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
[[UIApplication sharedApplication] openURL:fileURL];
also
NSURL *fileURL = [[NSBundle mainBundle] URLForResource: #"test" withExtension:#"ext"];
[[UIApplication sharedApplication] openURL:fileURL];
also manually using strings with different variations of localhost/ and file:// and var/mobile etc paths
nothing works (for me anyway)
So, I looked around SO and came across UIDocumentInteractionController
I am able to use UIDocumentInteractionController to let the user open my local file with the other app - however it always present multiple options of other apps to use and for example, one of the other apps can be 'Dropbox'.
I do not want to let the user download (or upload technically) a copy of my file for their use in other ways. It contains data that I would prefer not to make so readily available.
When the file is opened by my intended app (not made by me btw) it does not allow any kind of saving or access to raw data.
I realize that by including the file in my app anyone who is serious about obtaining it will be able to, I just don't want to flash a big menu saying 'Here it is if you want your own copy to make derivative work from'
Ideally, I could use openURL but I think it is because of the 'sandbox' that the other app doesn't respond - in Android I use mode_world_readable to declare the file as readable by other apps (therefore placing it outside the sandbox, and it doesn't allow other apps to write to it, just read) - is there anyway of doing the same with iOS?
Otherwise, if I could force UIDocumentInteractionController to use a specific app and not present the menu - that would be fine too.
Similar question asked a while ago
Sorry about the long read, any help is appreciated.
Edit:
I just received an answer from Apple Tech support and they told me that this is currently impossible (just after iOS 6 released)
Yes, you're limited because of the strict sandboxing on iOS. Here are some thoughts.
You can override the functionality of the UIDocumentInteractionController by instead subclassing QLPreviewController. You can then replace the standard bar button item that displays the "Open in" menu. Take a look at this post for one solution for subclassing QLPreviewController: QLPreviewController remove or add UIBarButtonItems
Of course, I believe the way inter-app sharing works is largely out of your hands. If an app has registered to be able to handle a certain type of file, it is going to display as one of the choices in the "open in" list whether you want it to or not. I don't believe you can filter which apps display in that list.
Here are two experimental ideas I've thought about but have never tried:
You could base64 encode the data from the file you're trying to pass along--which just converts binary to text--and hand that off as part of the custom URL you use to launch the other app. Then the other app can base64 decode that same data back into binary. The down side there is that there is a limit to the length of the URL which means the "file" you're sending would have to be pretty small.
Next, and I don't even know if this is possible, but I wonder if you could use some steganograhpy algorithm to embed the document data inside an image and then hand that off to the camera roll. Then, the other app could open the camera roll and decode the image back into the data again. ... Yeah. I know... obscure, but it might be fun to try to implement. ;-)
Not sure if any of that helps, but you did say "any help is appreciated". ;-)
Best regards.

Uploading Plist to FTP

I've been googling a lot about this issue, and I just couldn't find the best answer for me.
My program creates plist file from user inputs such like "name", "phone" etc..
While I'm trying to save it to docs, all works fine.
I'm using:
[thePlist writeToFile:thePath atomically:YES];
Now, I want to save it on my FTP server.
I tried this code and it doesn't work:
[plistData writeToURL:[NSURL URLWithString:#"ftp://User:PassWord#DomainName"] atomically:YES];
(P.S. While typing the full address in safari, it is recognized and has no problem to access there, so the address is not the issue here.)
Thank you all for the help!
NSData writeToURL only supports the "file://" scheme. So that will not work.
The best is probably to post the data with http to the server and have code on the server to accept the post.
From Apple's documentation:
The location to which to write the receiver's bytes. Only file:// URLs are supported.
Since at present only file:// URLs are supported, there is no difference between this method and writeToFile:atomically:, except for the type of the first argument.

What is the best way to store strings in iPhone application?

I'm wondering what is the best way to store long strings in iPhone? e.g. I have 'about' page in my app which is basically an html page, and I load it to UIWebView.
Is there any better way so store it apart from store it as string in code? may be in resource file?
Thank you
You can add the html file directly as a resource in your bundle. Then when you want to use it you can use the following code
NSString* fileName = [[NSBundle mainBundle] fileForResource:#"myHtmlFile" withExtension:#"html"];
NSString* fileContents = [NSString stringWithContentsOfFile:fileName encoding:NSUTF8Encoding error:nil];
[webView loadHTMLString:fileContents baseURL:baseURL];
You can use a plist that is very flexible and fast to load.
If you plan to localize this text into different language you should use String File (both are available under "Resource" when you choose to create a new file in xcode)
I haven't done this myself, but I'm guessing you could simply deploy an HTML file with your bundle (just add it as a resource to your project) and point the UIWebView at it.
If the string will never change throughout the life of the application, you should use a resource packaged in your application bundle.
As the previous posts alluded to, you have several options. You can make a plist, an HTML file, or any other kind of file resource.
A nice benefit of these options is that you have the ability to make localized versions.
If the string will change through use of the application, you may also consider storing the value of the string in a local database with SQLite and CoreData.

Launch my app using email attachement

I want to bind my app to some file extension so when I receive an email with an attached file with the correct extension, clicking on it will launch my app and pass it the attached file.
Is it possible ? How ?
Thx
--G.
As iPhone applications are not allowed to share files on the file system, what you're looking for is not immediately possible (not with the published APIs that I know of, anyway). You might still have a couple of options though.
Either way you'll have to use a custom URL scheme, which is associated with your app, and paste that into your email. This URL might point to some external location, which your app can download the file from.
Or it might contain the actual file contents if it's fairly small. URLs are 'just text' (some restrictions apply), so you're free to put any data you want to in it, as long as it is URL-encoded.
You still need to get the URL into the email though, which might or might not be as easy as attaching a file.
It's not possible to simply associate a file extension with an application on the iPhone.
You could create a custom URL scheme that would launch your app, but probably that won't help you.
This is actually possible, I'm working on this exact same problem and this great tutorial has really helped me.