Code Monkey home page Code Monkey logo

Comments (5)

rlepinski avatar rlepinski commented on July 17, 2024

@vasklund I believe you can have a different AirshipConfig.plist files included in each target. The SDK will pick up the one for the target.

How are you accomplishing this on Android?

from react-native-airship.

vasklund avatar vasklund commented on July 17, 2024

Interesting, I will give this a try on Monday! My iOS development skills are still very lacking :)

Is there any analogous way to do this for Android? Right now I just use a custom AutoPilot on Android. Something like

<meta-data
  android:name="com.urbanairship.autopilot"
  android:value="se.svd.start.MyAutopilot"
  tools:replace="android:value"
/>

in AndroidManifest.xml, then I load my config file in
public AirshipConfigOptions createAirshipConfigOptions(@NonNull Context context) like this:

Properties properties = new Properties();
try {
  InputStream inputStream = context.getAssets().open("airshipconfig_" + BuildConfig.PRODUCT + ".properties");
  properties.load(inputStream);
} catch (IOException e) {
  throw new RuntimeException(e);
}

where PRODUCT is a config variable injected via react-native-config.

from react-native-airship.

vasklund avatar vasklund commented on July 17, 2024

(Right now we build the config "by hand" with

return new AirshipConfigOptions.Builder()
  .setDevelopmentAppKey(...)
  .setDevelopmentAppSecret(...)

etc., but I realized (but haven't confirmed) today that we can probably just do

return new AirshipConfigOptions.Builder()
  .applyProperties(context, "airshipconfig_" + BuildConfig.PRODUCT + ".properties")
  .setCustomThing("myCustomRuntimeValue");

instead.)

from react-native-airship.

rlepinski avatar rlepinski commented on July 17, 2024

Yeah you could do that for Android instead of loading the properties file by hand. Another option is to take advantage of the "flavors" feature of Android and have a AirshipConfig.properites file per flavor.

from react-native-airship.

vasklund avatar vasklund commented on July 17, 2024

I've got it working now, it was indeed possible to do it simply using targets for iOS and product flavors for Android. Less code and easier to understand IMHO.

Thanks for your help!

from react-native-airship.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.