I want to use the PositionService
of Gluon Mobile on iOS. I have written a small sample app that runs on desktop, providing (as intended) fake location changes, and on Android. On the iOS simulator, however, the listener is not called. Here is the relevant part of the code:
public class BasicView extends View {
private static final Logger LOGGER = Logger.getLogger(BasicView.class.getName());
final Label label;
public BasicView(String name) {
super(name);
label = new Label();
VBox controls = new VBox(15.0, label);
controls.setAlignment(Pos.CENTER);
setCenter(controls);
// get current position
Platform p = PlatformFactory.getPlatform();
PositionService ps = p.getPositionService();
outputPos(ps.getPosition());
ps.positionProperty().addListener((obs, oldPos, newPos) -> {
LOGGER.log(Level.INFO, "\nobs: {0}\noldPos: {1}\nnewPos: {2}",
new Object[]{obs, oldPos, newPos});
outputPos(newPos);
});
}
private void outputPos(Position p) {
if (p != null) {
label.setText(String.format("We are currently here: %f %f",
p.getLatitude(),
p.getLongitude()));
}
}
@Override
protected void updateAppBar(AppBar appBar) {
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> System.out.println("Menu")));
appBar.setTitleText("Basic View");
appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e -> System.out.println("Search")));
}
}
I have added libCharm.a, but as far as I can tell it should not be needed here.
I also found hints on updating the info.plist as follows, but with or without it the listener is not called.
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>location-services</string>
</array>
...
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required to find out where you are</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is required to find out where you are</string>
The only output regarding location I see is this:
Aug 27, 2016 1:37:31 PM com.gluonhq.charm.down.ios.IOSPositionService <init>
INFO: Location Manager configured with desiredAccuracy 10.00 and distanceFilter 100.00
Aug 27, 2016 1:37:31 PM com.gluonhq.charm.down.ios.IOSPositionService <init>
INFO: Telling LocationManager to start updating location.
I guess I am missing something here... As always, any help is greatly appreciated.
EDIT: Sorry, forgot build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.thomaskuenneth.gluon.positionservicedemo.PositionServiceDemo'
dependencies {
compile 'com.gluonhq:charm:3.0.0'
androidRuntime 'com.gluonhq:charm-android:3.0.0'
iosRuntime 'com.gluonhq:charm-ios:3.0.0'
desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
compileSdkVersion = 23
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}