MKMapKit on iOS 6 and Google Maps on older devices - iphone

I'd like to show maps on iOS 6 by using MKMapItem but I'd also like to use Google Maps for older iOS versions.
When I test my solution on iOS 5.1 I have this error
dyld: Symbol not found: _MKLaunchOptionsDirectionsModeDriving
This is my code :
if Utils.older_than_ios6?
url = "http://maps.google.com/maps?saddr=#{#party.place.location[1]},#{#party.place.location[0]}&daddr=#{#party.place.location[1]},#{#party.place.location[0]}"
App::open_url(url)
else
address_dictionnary = ({kABPersonAddressStreetKey: #party.place.street, kABPersonAddressCityKey: #party.place.city,kABPersonAddressZIPKey: #party.place.postal_code})
place = MKPlacemark.alloc.initWithCoordinate(#coords, addressDictionary: address_dictionnary)
mapItem = MKMapItem.alloc.initWithPlacemark(place)
mapItem.name = "#{#party.name}"
options = ({
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
})
mapItem.openInMapsWithLaunchOptions(options)
end

This link shows that MKLaunchOptionsDirectionsModeDriving is available only on iOS6+.
And just to be sure, did you add MapKit to the list of frameworks in your Rakefile ?

Related

i need help in adding facebook share into my ios application

i am trying to add facebook share dialog into my ios application and i found the official page from facebook on how to do it, but i run into a problem about ContentProtocol. i dont know what that is. here is the link to the guidence that i use . it is pretty straight forward. basically just install the pod facebookshare, import it and add few line of code, but i got problem on 'myContent'
here is the code
import FacebookShare
let shareDialog = ShareDialog(content: myContent)
shareDialog.mode = .Native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
// Handle share results
}
try shareDialog.show()
here is the link
https://developers.facebook.com/docs/swift/sharing/share-dialog
what should i put in the myContent?
I guess next link is explained what you can use as content and how to use it
Content-types
(From documentation) Currently, the Facebook SDK for Swift can share 4 different kinds of content:
Links - Represented by the LinkShareContent object.
Photos - Represented by the PhotoShareContent object.
Videos - Represented by the VideoShareContent object.
Open Graph - Represented by the OpenGraphShareContent object.
you can use FBSDKShareLinkContent
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "//URL")
content.contentTitle = "MyApp"
content.contentDescription = "//Desc"
content.imageURL = NSURL(string:"//Image URL")

How to show the path of a workout using Facebook Open Graph Stories in iOS - Result is different on Facebook App versus iPhone Browser

I have this code to share workout data on Facebook. My intention is to eventually show a path of the run/walk. But I have this confusion at the moment. If I execute this code and look at my Facebook page on either iOS Facebook App, or any browser on a computer (Mac for example) I see only the distance and some other information. But when I look at my post on a browser on an iOS device (logged in my Facebook account on either Safari or Chrome on iPhone) I see a map (See images attached). My question is why is there a difference on the look of the post depending on how I view it? And how can I show the map on the post to the Facebook App? I am using the latest Facebook SDK for iOS: Version 4.28.0
func shareOnFacebook () {
// Create an object
let properties = ["og:type": "fitness.course",
"og:title": "Title",
"og:description": "Description",
"fitness:duration:value": 1200,
"fitness:duration:units": "s",
"fitness:distance:value": 4.3,
"fitness:distance:units": "mi",
"fitness:metrics:location:latitude": 36.9926439,
"fitness:metrics:location:longitude": -102.0419088,
"fitness:metrics:location:altitude" :42,
"fitness:metrics:timestamp" :"2017-11-18T00:00",
"fitness:metrics:distance:value" : 0,
"fitness:metrics:distance:units":"mi" ,
"fitness:metrics:pace:value" :0,
"fitness:metrics:pace:units" :"s/m",
"fitness:metrics:calories":0] as [String : Any]
let object = FBSDKShareOpenGraphObject(properties: properties)
// Create an action
let action = FBSDKShareOpenGraphAction()
action.actionType = "fitness.run"
action.setObject(object, forKey: "fitness:course")
// Create the content
let content = FBSDKShareOpenGraphContent()
content.action = action
content.previewPropertyName = "fitness:course"
let shareDialog = FBSDKShareDialog()
shareDialog.fromViewController = self
shareDialog.shareContent = content
if shareDialog.canShow() {
shareDialog.show()
}
}

BlackBerry Cascades 10 Maps example keeps showing black screen

I am trying to run the maps example Qml however my MapView keeps loading as a just black. I checked the console output and spotted this.
slogger2 buffer handle not initialized. ../../lgmon_api.c, logEvent(), around line 578!
cpp:: Created document
cpp:: properties set
MapViewPrivate::removeRenderEngine
using the following render engine: bb::cascades::maps::BlankRenderEngine
MapViewPrivate::removeRenderEngine
removing the old render engine: bb::cascades::maps::BlankRenderEngine
RenderEngineManager::RenderEngineManager
RenderEngineManager::scanForPlugins()
render engine search: searching QDir( "/apps/com.example.GConnectBB.testDev__GConnectBB7836cab4/native/mapview-renderengine" , nameFilters = { * }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
render engine search: searching QDir( "/base/usr/lib/qt4/plugins/mapview-renderengine" , nameFilters = { * }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
render engine search: attempting to load "/base/usr/lib/qt4/plugins/mapview-renderengine/libRenderEngine3d.so"
unknown symbol: _ZTIN2bb8platform3geo11GeoLocationE
unknown symbol: _ZTIN2bb8platform3geo11GeoLocationE
unknown symbol: _ZNK2bb8platform3geo11GeoLocation10metaObjectEv
unknown symbol: _ZN2bb8platform3geo11GeoLocation11qt_metacastEPKc
unknown symbol: _ZN2bb8platform3geo11GeoLocation11qt_metacallEN11QMetaObject4CallEiPPv
unknown symbol: _ZNK2bb8platform3geo11GeoLocation11boundingBoxEv
unknown symbol: _ZTIN2bb8cascades4maps17BlankRenderEngineE
unknown symbol: _ZN2bb8cascades4maps17BlankRenderEngine16staticMetaObjectE
unknown symbol: _ZTIN2bb8platform3geo10GeographicE
RenderEngineManager::engine( <ViewProperties altitude=0, heading=0, lat=43.4682, lon=-80.5196, tilt=0, window=QSize(0, 0) > )
using the following render engine: bb::cascades::maps::BlankRenderEngine
So it looks like it is not loading a proper render engine for my map. I tried updating my SDK and updated the OS on the phone using the blackberry OS update to no avail.
Here is the full Qml for my map:
import bb.cascades 1.0
import bb.cascades.maps 1.0
Page {
Container {
layout: StackLayout {
}
MapView {
id: mapview
latitude: 43.468245
longitude: -80.519603
altitude: 10000
}
}
}
More details:
OS Version: 10.9.10.35
Native SDK: 10.0.9.1673
Momentics Version: 10.0.9
I tried another SDK version too, 10.0.10.xxx and it didn't work either.
As #Hithredin mentioned above in a comment, in order to have maps functionality you need to make sure that you specified all the libraries to link for linker in your .pro file:
LIBS += -lbbplatform -lbbcascadesmaps -lGLESv1_CM
and also if you're using geolocation (which happens pretty often when you use maps) you need to have the following set of permissions in your bar-descriptor.xml file:
<permission>read_geolocation</permission>
<permission>access_location_services</permission>
More about maps and location on Blackberry dev site:
Location documentation
Maps documentation
make sure to include
#include <bb/cascades/maps/MapView>
in your ApplicationUI.hpp or ApplicationUI.cpp.

MKMapItem recognized in iOS 5?

So I'm using NSClassFromString to check if the user has iOS 5 or iOS 6 installed to use Apple's new iOS 6 MKMapItem. This is the code:
- (void)openDirections:(id)sender {
Class mapClass = NSClassFromString(#"MKMapItem");
if (mapClass == nil) {
// iOS 5, do something here
}
else {
// iOS 6, open up maps with MKMapItem.
}
}
By the code above, when I run it on iOS 5.1 simulator or a iOS 5.1 device, the iOS 6 branch gets run. However, if I use
Class mapClass = NSClassFromString(#"PKPass");
which was also introduced in iOS 6, my code follows the appropriate iOS 5 or iOS 6 branch. Am I missing something? Thanks.
MKMapItem exists in prior versions of iOS because it was in development then, therefore the class existed. Instead, Apple recommends that you should use the following code also checking for a method they specifically added in iOS 6.0:
Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:#selector(openMapsWithItems:launchOptions:)]) {
// Use class
}
Information from MKMapItem Class Reference

what dows TTIsPad() do in Xcode using Three20?

i'm using Three20 in XCode but i copied a piece of code like this:
if (TTIsPad()) {
SplitCatalogController* controller =
(SplitCatalogController*)[[TTNavigator navigator] viewControllerForURL:#"tt://catalog"];
SplitCatalogController* controller =
(SplitCatalogController*)[[TTNavigator navigator] viewControllerForURL:#"tt://catalog"];
TTDASSERT([controller isKindOfClass:[SplitCatalogController class]]);
map = controller.rightNavigator.URLMap;
}
But i don't know what does the function TTIsPad do, please help me.
It is a convenience method that returns true if the current device is an iPad, and false otherwise.
The source can be found here. It first checks whether the device is running iOS 3.2 or greater. If not, it returns false (iPads shipped with 3.2) If it is greater than 3.2, it returns the result of (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) which is true only if the device is an iPad.