
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-native-deltadna
Advanced tools
Integrating DeltaDNA Game Analytics into your React Native app.
$ npm install react-native-deltadna
(If you want to persist the installed package in your package.json
, add --save
to this command.)
Call react-native link
to link the native parts against your application and continue with Additional configuration
.
android/app/src/main/java/[...]/MainApplication.java
import com.playable.deltadna.RNDeltaDNAPackage;
to the imports at the top of the filenew RNDeltaDNAPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-deltadna'
project(':react-native-deltadna').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-deltadna/android')
android/app/build.gradle
:
compile project(':react-native-deltadna')
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-deltadna
and add RNDeltaDNA.xcodeproj
libRNDeltaDNA.a
to your project's Build Phases
➜ Link Binary With Libraries
Cmd+R
)Since this package relies on a third party library, there are a few additional things that need to be configured.
In order for DeltaDNA to be correctly initialized, we need to overwrite the onCreate
method in the main application:
package com.example;
/* ... */
import com.playabl.deltadna.RNDeltaDNAModule;
public class MainApplication extends Application implements ReactApplication {
/* ... */
@Override
public void onCreate() {
super.onCreate();
RNDeltaDNAModule.setApplication(this);
}
}
DeltaDNA uses their own repository, we need to add it to the android/build.grade
file in the allprojects -> repositories
section. In the end, this section should look something like this:
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "http://deltadna.bintray.com/android"
}
}
}
For iOS, the application needs to link against DeltaDNA
. This can be done in different ways:
DeltaDNA.framework
to your application by compiling the DeltaDNA
library first and then adding it as a dependency into your applicationDeltaDNA.xcodeproj
as a dependency into your applicationAllow HTTP communication in your iOS app by setting the following keys in your Info.plist
file:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
To run the example, add credentials.json
to root level of the example folder. It needs to be in form of:
{
"environmentKey": "<My Environment Key, actual numbers as a string here please>",
"collectURL": "<CollectURL here please>",
"engageURL": "<EngageURL here please>"
}
For iOS, run npm run download-deltadna-ios
to set up the DeltaDNA SDK in the example directory. The example project is expecting the SDK to be in this folder.
With the DeltaDNA's iOS and Android SDK being slightly different in terms of their API, this library tends to implement a common superset of both APIs which follows the API of the iOS SDK more closely than the Android SDK.
To access DeltaDNA
in your React Native application, import the module first.
import DeltaDNA from 'react-native-deltadna';
DeltaDNA.start
DeltaDNA.start({
environmentKey: 'My environment key',
collectURL: 'My collectURL',
engageURL: 'My engageURL',
userID: 'Optional, the userID for a session, will be automatically generated otherwise',
});
This method starts the DeltaDNA SDK and by extension, emits the newPlayer
, gameStarted
and clientDevice
events by default.
This function needs to be called at the start of the application.
DeltaDNA.stop
DeltaDNA.stop();
Stops the SDK and emits the gameEnded
event.
DeltaDNA.newSession
DeltaDNA.newSession();
Starts a new session
DeltaDNA.upload
DeltaDNA.upload();
By default, DeltaDNA uploads all new data every minute. If you want or need to force an upload, call this method.
DeltaDNA.clearPersistantData
DeltaDNA.clearPersistantData();
Clears all data on the device.
DeltaDNA.recordEvent
DeltaDNA.recordEvent({
name: 'missionCompompleted',
});
This method uploads an event to with the specified name
. name
is the only property that's necessarily needed. If you need send additional parameters as well, simply define a params
property.
DeltaDNA.recordEvent({
name: 'missionCompleted',
params: {
level: 5,
},
});
DeltaDNA.recordPushNotification
DeltaDNA.recordPushNotification({
name: 'PushNotification',
}, false);
Upload a notificationOpened
event. On iOS, a payload can be defined as the first parameter, while the payload does not have any effect on Android. The second parameter indicates if the notification was used to open the app (if true
) or if the app was already running.
DeltaDNA.engage
DeltaDNA.engage({
name: 'Engagement'
}, result => {
alert(result);
});
Similar to sending an event with the difference that we can react to the response with a callback. Params can be added in the same way they are added to events.
MIT, see LICENSE
FAQs
DeltaDNA integration for React Native
The npm package react-native-deltadna receives a total of 3 weekly downloads. As such, react-native-deltadna popularity was classified as not popular.
We found that react-native-deltadna demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.