-
Notifications
You must be signed in to change notification settings - Fork 3
Removing Expo support #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
ebc04a4
24c498e
1d2075b
100759f
17b9724
44e491e
efb5e4d
27e09e0
4536775
8c26d9f
1e6955e
7f797a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ | |
|
|
||
| public class RNBatchModuleImpl { | ||
|
|
||
| public static final String NAME = "RNBatch"; | ||
| public static final String NAME = "RNBatchModule"; | ||
|
|
||
| private static final String PLUGIN_VERSION_ENVIRONMENT_VARIABLE = "batch.plugin.version"; | ||
|
|
||
|
|
@@ -66,7 +66,7 @@ public class RNBatchModuleImpl { | |
| private static final RNBatchEventDispatcher eventDispatcher = new RNBatchEventDispatcher(); | ||
|
|
||
| static { | ||
| System.setProperty("batch.plugin.version", PLUGIN_VERSION); | ||
| System.setProperty(PLUGIN_VERSION_ENVIRONMENT_VARIABLE, PLUGIN_VERSION); | ||
| } | ||
|
|
||
| private static boolean isInitialized = false; | ||
|
|
@@ -77,31 +77,31 @@ public static Map<String, Object> getConstants() { | |
|
|
||
| public static void initialize(Application application) { | ||
| if (!isInitialized) { | ||
| Log.i(LOGGER_TAG, "Initializing module"); | ||
| Resources resources = application.getResources(); | ||
| String packageName = application.getPackageName(); | ||
| setDefaultProfileMigrations(application.getApplicationContext(), packageName); | ||
| setDefaultConfig(application.getApplicationContext(), packageName); | ||
| String batchAPIKey = resources.getString(resources.getIdentifier("BATCH_API_KEY", "string", packageName)); | ||
| Batch.start(batchAPIKey); | ||
| Batch.EventDispatcher.addDispatcher(eventDispatcher); | ||
| try { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Un interet particulier de le déplacer dans
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ouai parce que la valeur est lue via le manifest maintenant et plus par les string resources (sinon ca faisait utiliser un dangerous mod coté expo), donc du tout j'uniformise toute les valeurs lue via le manifest au même endroit (d'ou le rename de la méthode). |
||
| boolean doNotDisturbEnabled = resources.getBoolean(resources.getIdentifier("BATCH_DO_NOT_DISTURB_INITIAL_STATE", "bool", packageName)); | ||
| Batch.Messaging.setDoNotDisturbEnabled(doNotDisturbEnabled); | ||
| } catch (Resources.NotFoundException e) { | ||
| Batch.Messaging.setDoNotDisturbEnabled(false); | ||
| } | ||
|
|
||
| application.registerActivityLifecycleCallbacks(new BatchActivityLifecycleHelper()); | ||
|
|
||
| isInitialized = true; | ||
| } else { | ||
| Log.w(LOGGER_TAG, "Module already initialized"); | ||
| } | ||
| } | ||
|
|
||
| public static void setDefaultProfileMigrations(Context context, String packageName) { | ||
| public static void setDefaultConfig(Context context, String packageName) { | ||
| try { | ||
| Bundle metaData = context.getPackageManager() | ||
| .getApplicationInfo(packageName, PackageManager.GET_META_DATA) | ||
| .metaData; | ||
| if (metaData != null) { | ||
| // DnD Initial State | ||
| boolean doNotDisturbEnabled = metaData.getBoolean("batch_do_not_disturb_initial_state", false); | ||
| Batch.Messaging.setDoNotDisturbEnabled(doNotDisturbEnabled); | ||
|
|
||
| // Profile Migrations | ||
| boolean profileCustomIdMigrationEnabled = metaData.getBoolean("batch.profile_custom_id_migration_enabled", true); | ||
| boolean profileCustomDataMigrationEnabled = metaData.getBoolean("batch.profile_custom_data_migration_enabled", true); | ||
| EnumSet<BatchMigration> migrations = EnumSet.noneOf(BatchMigration.class); | ||
|
|
@@ -122,6 +122,14 @@ public static void setDefaultProfileMigrations(Context context, String packageNa | |
|
|
||
|
|
||
| public RNBatchModuleImpl(ReactApplicationContext reactContext) { | ||
| if(!isInitialized) { | ||
| Application app = (Application) reactContext.getApplicationContext(); | ||
| if (app != null) { | ||
| initialize(app); | ||
| } else { | ||
| Log.e(LOGGER_TAG, "Application context is null, cannot initialize Batch module"); | ||
| } | ||
| } | ||
| this.reactContext = reactContext; | ||
| this.batchInboxFetcherMap = new HashMap<>(); | ||
| eventDispatcher.setReactContext(reactContext); | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,7 @@ | ||
| #import <React/RCTEventEmitter.h> | ||
| #import <Batch/Batch.h> | ||
|
|
||
| #define PluginVersion "ReactNative/11.1.0" | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| #import <RNBatchSpec/RNBatchSpec.h> | ||
| @interface RNBatch: RCTEventEmitter <NativeRNBatchModuleSpec> | ||
| #else | ||
| #import <React/RCTBridgeModule.h> | ||
| @interface RNBatch: RCTEventEmitter <RCTBridgeModule> | ||
| #endif | ||
|
|
||
| + (void)start; | ||
| @interface RNBatch: NSObject | ||
|
|
||
| @property (nonatomic, strong) NSMutableDictionary<NSString *, BatchInboxFetcher *> *batchInboxFetcherMap; | ||
| +(void)start; | ||
|
|
||
| @end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,33 @@ | ||
| # import <React/RCTConvert.h> | ||
| # import "RNBatch.h" | ||
| # import "RNBatchOpenedNotificationObserver.h" | ||
| # import "RNBatchEventDispatcher.h" | ||
| # import "BatchBridgeNotificationCenterDelegate.h" | ||
| #import <Batch/Batch.h> | ||
| #import <React/RCTConvert.h> | ||
| #import "RNBatch.h" | ||
| #import "RNBatchOpenedNotificationObserver.h" | ||
| #import "RNBatchEventDispatcher.h" | ||
| #import "BatchBridgeNotificationCenterDelegate.h" | ||
| #import <React/RCTEventEmitter.h> | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| #import "RNBatchSpec.h" | ||
| #endif | ||
|
|
||
| static RNBatchEventDispatcher* dispatcher = nil; | ||
|
|
||
| @implementation RNBatch | ||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| #import <RNBatchSpec/RNBatchSpec.h> | ||
| @interface RNBatchModule: RCTEventEmitter <NativeRNBatchModuleSpec> | ||
| #else | ||
|
||
| #import <React/RCTBridgeModule.h> | ||
| @interface RNBatchModule: RCTEventEmitter <RCTBridgeModule> | ||
| #endif | ||
|
|
||
| + (void)start; | ||
|
|
||
| @property (nonatomic, strong) NSMutableDictionary<NSString *, BatchInboxFetcher *> * batchInboxFetcherMap; | ||
|
|
||
| @end | ||
|
|
||
|
|
||
| @implementation RNBatchModule | ||
|
|
||
| + (BOOL)requiresMainQueueSetup | ||
| { | ||
|
|
@@ -112,7 +129,7 @@ - (NSDictionary*)getConstants { | |
| if (BatchSDK.isOptedOut) { | ||
| // Opt-in SDK | ||
| [BatchSDK optIn]; | ||
|
|
||
| // Get API key and restart sdk | ||
| NSDictionary *info = [[NSBundle mainBundle] infoDictionary]; | ||
| NSString *batchAPIKey = [info objectForKey:@"BatchAPIKey"]; | ||
|
|
@@ -959,3 +976,11 @@ - (NSDictionary*) dictionaryWithNotification:(BatchInboxNotificationContent*)not | |
| #endif | ||
|
|
||
| @end | ||
|
|
||
| @implementation RNBatch | ||
|
|
||
| + (void) start | ||
| { | ||
| [RNBatchModule start]; | ||
| } | ||
| @end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # import "RNBatch.h" | ||
| #import <Batch/Batch.h> | ||
|
|
||
| @interface RNBatchEvent : NSObject | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas de changement pour iOS ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nan on a pas de breaking change coté ios, l'init du plugin était déjà manuelle et l'api à pas changée.