Skip to content

Commit

Permalink
chore: refactors example android project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-haripriyan committed Jan 31, 2023
1 parent b556fbc commit a7523d2
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 10 deletions.
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
classpath "com.android.tools.build:gradle:7.4.0"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.facebook.react:react-native-gradle-plugin"
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.chargebee.android
package com.chargebee.example

import com.chargebee.android.Chargebee
import com.chargebee.android.ChargebeeReactNativeSpec
import com.chargebee.android.billingservice.CBPurchase
import com.chargebee.android.exceptions.CBProductIDResult
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReadableMap

class ChargebeeReactNativeModule internal constructor(context: ReactApplicationContext) :
ChargebeeReactNativeSpec(context) {
Expand All @@ -16,6 +21,27 @@ class ChargebeeReactNativeModule internal constructor(context: ReactApplicationC
Chargebee.configure(site, publishableApiKey, true, sdkKey)
}

@ReactMethod
override fun retrieveProductIdentifiers(queryParams: ReadableMap, promise: Promise) {
var formattedQueryParams = arrayOf<String>()
if (queryParams != null)
formattedQueryParams = arrayOf(queryParams.getString("limit") ?: "")
CBPurchase.retrieveProductIdentifers(formattedQueryParams) {
when (it) {
is CBProductIDResult.ProductIds -> {
if (it.IDs.isNotEmpty()) {
promise.resolve(it)
}
}
is CBProductIDResult.Error -> {
promise.reject(it.exp.message, it.exp)
}
}
}

}


companion object {
const val NAME = "ChargebeeReactNative"
}
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ android {

compileSdkVersion rootProject.ext.compileSdkVersion

namespace "com.chargebeereactnativeexample"
namespace "com.chargebee.example"
defaultConfig {
applicationId "com.chargebeereactnativeexample"
applicationId "com.chargebee.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package com.chargebeereactnativeexample;
package com.chargebee.example;

import android.content.Context;
import com.facebook.flipper.android.AndroidFlipperClient;
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MainApplication"
android:name="com.chargebee.example.MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:name="com.chargebee.example.MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.chargebeereactnativeexample;
package com.chargebee.example;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.chargebeereactnativeexample;
package com.chargebee.example;

import android.app.Application;

import com.chargebee.example.BuildConfig;
import com.chargebee.example.ReactNativeFlipper;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package com.chargebeereactnativeexample;
package com.chargebee;

import android.content.Context;
import com.facebook.react.ReactInstanceManager;
Expand Down

0 comments on commit a7523d2

Please sign in to comment.