reactnative-plugin-appice 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +30 -0
- package/example/package.json +1 -1
- package/index.js +59 -2
- package/ios/AppIceReactPlugin.m +24 -0
- package/ios/AppIceReactPlugin.xcodeproj/xcuserdata/user214879.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/user214879.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/user214879.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +1 -1
|
@@ -347,6 +347,36 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
347
347
|
ContextSdk.pushNotificationClicked(payload, ctx);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
//===========================================
|
|
353
|
+
// Device Setting
|
|
354
|
+
//===========================================
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* To set the custom device_id.
|
|
358
|
+
*/
|
|
359
|
+
@ReactMethod
|
|
360
|
+
public void setInternalId(String deviceId){
|
|
361
|
+
//TODO{ we can not call setDevice Id here because it
|
|
362
|
+
// will directly call start context with new device id
|
|
363
|
+
// but here we want to store the data only
|
|
364
|
+
// }
|
|
365
|
+
//ContextSdk.setInternalId();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* To get the ad_id from sdk.
|
|
370
|
+
*
|
|
371
|
+
* @callback will have the string
|
|
372
|
+
*/
|
|
373
|
+
@ReactMethod
|
|
374
|
+
public void getDeviceId(Callback callback){
|
|
375
|
+
Context context = getReactApplicationContext();
|
|
376
|
+
callback.invoke(ContextSdk.getInternalId(context));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
|
|
350
380
|
public static void sendEvent(String eventName, @Nullable WritableMap params) {
|
|
351
381
|
try {
|
|
352
382
|
context.
|
package/example/package.json
CHANGED
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Platform, Component } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
5
5
|
var eventEmitter;
|
|
6
|
+
|
|
6
7
|
if(Platform.OS === 'ios')
|
|
7
8
|
{
|
|
8
9
|
eventEmitter = NativeModules.AppICEReactEvent ? new NativeEventEmitter(NativeModules.AppICEReactEvent) : DeviceEventEmitter;
|
|
@@ -58,10 +59,20 @@ var AppICEReact = {
|
|
|
58
59
|
* @param {string} region - e.i. US/GCC/IND
|
|
59
60
|
* @param {string} baseUrl -
|
|
60
61
|
* @param {object} certs - arrays of certificate paths
|
|
61
|
-
*
|
|
62
|
+
* startContext executes after getDeviceId callback
|
|
63
|
+
* if res exist assign the value of res else assign deviceID
|
|
62
64
|
*/
|
|
63
65
|
startContext: function (appID, appKey, apiKey, deviceID, region, baseUrl, certs){
|
|
64
|
-
|
|
66
|
+
this.getDeviceId(( res ) =>
|
|
67
|
+
{
|
|
68
|
+
if(res){
|
|
69
|
+
console.log('Res variable'+res);
|
|
70
|
+
AppIceReactPlugin.startContext(appID, appKey, apiKey, res, region, baseUrl, certs)
|
|
71
|
+
}else{
|
|
72
|
+
console.log('deviceID variable'+deviceID);
|
|
73
|
+
AppIceReactPlugin.startContext(appID, appKey, apiKey, deviceID, region, baseUrl, certs)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
65
76
|
},
|
|
66
77
|
|
|
67
78
|
/**
|
|
@@ -118,7 +129,53 @@ var AppICEReact = {
|
|
|
118
129
|
|
|
119
130
|
return map;
|
|
120
131
|
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* call this function before clearing old data from db/keychain
|
|
135
|
+
*/
|
|
136
|
+
preInitialise: function(){
|
|
137
|
+
|
|
138
|
+
this.getDeviceId(( res ) =>
|
|
139
|
+
{
|
|
140
|
+
|
|
141
|
+
if(res){
|
|
142
|
+
console.log('setInternalId');
|
|
143
|
+
this.setInternalId(res);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
//===============================================
|
|
149
|
+
// Device id setting
|
|
150
|
+
//===============================================
|
|
151
|
+
|
|
152
|
+
getDeviceId: function(callback){
|
|
153
|
+
callWithCallback ('getDeviceId', null, callback)
|
|
154
|
+
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
setInternalId: function (deviceId){
|
|
158
|
+
AppIceReactPlugin.setInternalId(deviceId);
|
|
159
|
+
},
|
|
160
|
+
|
|
121
161
|
};
|
|
122
162
|
|
|
163
|
+
// internal function for callback
|
|
164
|
+
function callWithCallback(method, args, callback) {
|
|
165
|
+
if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
|
|
166
|
+
callback = (err, res) => {
|
|
167
|
+
defaultCallback(method, err, res);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (args == null) {
|
|
172
|
+
args = [];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
args.push(callback);
|
|
176
|
+
|
|
177
|
+
AppIceReactPlugin[method].apply(this, args);
|
|
178
|
+
}
|
|
179
|
+
|
|
123
180
|
|
|
124
181
|
module.exports = AppICEReact;
|
package/ios/AppIceReactPlugin.m
CHANGED
|
@@ -185,6 +185,30 @@ RCT_EXPORT_METHOD(inAppClicked:(NSDictionary*)userInfo)
|
|
|
185
185
|
}];
|
|
186
186
|
|
|
187
187
|
}
|
|
188
|
+
RCT_EXPORT_METHOD(setInternalId:(NSString*) internalId)
|
|
189
|
+
{
|
|
190
|
+
[[appICE sharedInstance] setInternalId:internalId];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Call the native method to getDeviceId
|
|
195
|
+
* Check if the internal ID is not nil and the callback function is provided
|
|
196
|
+
* else Handle the case when getDeviceId is nil
|
|
197
|
+
* Invoke the callback with an array containing NSNull to represent nil
|
|
198
|
+
*/
|
|
199
|
+
RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback)
|
|
200
|
+
{
|
|
201
|
+
NSString *getinternalId = [[appICE sharedInstance] getInternalId];
|
|
202
|
+
RCTLog(@"getinternalID %@", getinternalId);
|
|
203
|
+
|
|
204
|
+
if (getinternalId != nil && callback) {
|
|
205
|
+
callback(@[getinternalId]);
|
|
206
|
+
} else {
|
|
207
|
+
if (callback) {
|
|
208
|
+
callback(@[[NSNull null]]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
188
212
|
|
|
189
213
|
@end
|
|
190
214
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>AppIceReactPlugin.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
Binary file
|
package/ios/Pods/Pods.xcodeproj/xcuserdata/user214879.xcuserdatad/xcschemes/xcschememanagement.plist
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Pods-AppIceReactPlugin.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>1</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|