radarlabs / react-native-radar

React Native module for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
170 stars 32 forks source link

setPlacesProvider doesn't work #78

Closed ste00martin closed 5 years ago

ste00martin commented 5 years ago

Describe the bug When I try to set the places provider in Android it fails to compile.

To Reproduce Steps to reproduce the behavior: put in radar:

import io.radar.sdk.Radar;
...
  @Override
  public void onCreate() {
Radar.initialize(LIVE_RADAR_KEY);
Radar.setPlacesProvider("facebook");
  }

see the error output:

> Task :app:compileDebugJavaWithJavac FAILED
/Users/stefan-work/repos/volta/mobile/android/app/src/main/java/com/volta/android/MainApplication.java:125: error: incompatible types: String cannot be converted to RadarPlacesProvider
    Radar.setPlacesProvider("facebook");
                            ^

I also tried adding in RadarPlacesProvider to no avail:

import io.radar.sdk.Radar;
...
  @Override
  public void onCreate() {
Radar.initialize(LIVE_RADAR_KEY);
Radar.setPlacesProvider(RadarPlacesProvider.FACEBOOK);
  }

error output:

> Task :app:compileDebugJavaWithJavac FAILED
/Users/stefan-work/repos/volta/mobile/android/app/src/main/java/com/volta/android/MainApplication.java:125: error: cannot find symbol
    Radar.setPlacesProvider(RadarPlacesProvider.FACEBOOK);
                            ^
  symbol:   variable RadarPlacesProvider
  location: class MainApplication

Expected behavior setting the places provider should compile / work

Metadata (please complete the following information):

russellcullen commented 5 years ago

The enum version is correct, are you importing RadarPlacesProvider? Alternatively you can use Radar.RadarPlacesProvider since Radar is already imported.

It's worth noting that you can set places provider in JavaScript if that's more convenient

Radar.setPlacesProvider("facebook")
ste00martin commented 5 years ago

when I tried setting it in java as your suggestion I got the following error:

android/app/src/main/java/com/volta/android/MainApplication.java:127: error: cannot find symbol
    Radar.setPlacesProvider(Radar.RadarPlacesProvider);
                                 ^
  symbol:   variable RadarPlacesProvider
  location: class Radar
1 error

I'll just use the javascript for now but it'd be nice to show the steps to add it in on android via importing RadarPlacesProvider. your documentation doesn't state how to import that

russellcullen commented 5 years ago

Apologies for the confusion, we'll be sure to update the documentation.

And sorry I was a little unclear with my previous suggestion, you'll need to import the enum class RadarPlacesProvider as normal and use the FACEBOOK enum value as you had before. All of these are valid Java and should work:

import io.radar.sdk.Radar;
import io.radar.sdk.Radar.RadarPlacesProvider;

// ... Application class
@Override
public void onCreate() {
    Radar.setPlacesProvider(RadarPlacesProvider.FACEBOOK);
}

or alternatively

import io.radar.sdk.Radar;

// ... Application class
@Override
public void onCreate() {
    Radar.setPlacesProvider(Radar.RadarPlacesProvider.FACEBOOK);
}

you can even specify the fully qualified package and don't need to import at all, as long as Radar is in your classpath:

// ... Application class
@Override
public void onCreate() {
    io.radar.sdk.Radar.setPlacesProvider(io.radar.sdk.Radar.RadarPlacesProvider.FACEBOOK);
}

And please let us know if you have any more issues, always happy to help!