Skip to content

Feat: Add AdvertisingId Plugin #574

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

Merged
merged 22 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions example/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing

We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.

## Adding Android Packages

Add necessary Gradle Dependencies

```sh
implementation project(':segmentanalyticsreactnative')
implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
implementation project(':analyticsreactnativepluginadvertisingid')
```


Add project to `settings.gradle`

```sh
include ':analyticsreactnativepluginadvertisingid'
project(':analyticsreactnativepluginadvertisingid').projectDir = new File(rootProject.projectDir, '../../packages/plugins/plugin-advertising-id/android')
```

Add package to `MainActivity.java`

```sh
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// AnalyticsReactNativeExample:
// packages.add(new MyReactNativePackage());
packages.add(new AnalyticsReactNativePackage());
packages.add(new AnalyticsReactNativePluginAdvertisingIdPackage());
return packages;
}
```
2 changes: 1 addition & 1 deletion example/android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</natures>
<filteredResources>
<filter>
<id>1644522731203</id>
<id>0</id>
<name></name>
<type>30</type>
<matcher>
Expand Down
2 changes: 1 addition & 1 deletion example/android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
java.home=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
Expand Down
4 changes: 3 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
// apply plugin: 'com.google.gms.google-services'

import com.android.build.OutputFile

Expand Down Expand Up @@ -210,6 +210,8 @@ dependencies {
}

implementation project(':segmentanalyticsreactnative')
// implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
// implementation project(':analyticsreactnativepluginadvertisingid')

androidTestImplementation('com.wix:detox:+')
}
Expand Down
9 changes: 7 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- <uses-permission android:name="com.google.android.gms.permission.AD_ID"/> -->
<application
android:name=".MainApplication"
android:label="@string/app_name"
Expand All @@ -12,6 +12,10 @@
android:allowBackup="false"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<!-- <meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/> -->
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down Expand Up @@ -39,7 +43,8 @@
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme"
android:launchMode="singleTask">
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import com.segmentanalyticsreactnative.AnalyticsReactNativePackage;
// import com.analyticsreactnativepluginadvertisingid.AnalyticsReactNativePluginAdvertisingIdPackage;


public class MainApplication extends Application implements ReactApplication {

Expand All @@ -26,8 +28,8 @@ protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// AnalyticsReactNativeExample:
// packages.add(new MyReactNativePackage());
packages.add(new AnalyticsReactNativePackage());
// packages.add(new AnalyticsReactNativePluginAdvertisingIdPackage());
return packages;
}

Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
}
repositories {
Expand Down
4 changes: 2 additions & 2 deletions example/android/device_setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

avdmanager=$ANDROID_HOME/tools/bin/avdmanager
sdkmanager=$ANDROID_HOME/tools/bin/sdkmanager
avdmanager=$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager
sdkmanager=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
emulator=$ANDROID_HOME/emulator/emulator
green=`tput setaf 2`
reset=`tput sgr0`
Expand Down
3 changes: 3 additions & 0 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ include ':app'

include ':segmentanalyticsreactnative'
project(':segmentanalyticsreactnative').projectDir = new File(rootProject.projectDir, '../../packages/core/android')

// include ':analyticsreactnativepluginadvertisingid'
// project(':analyticsreactnativepluginadvertisingid').projectDir = new File(rootProject.projectDir, '../../packages/plugins/plugin-advertising-id/android')
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 0c7eb82d495ca56953c50916b7b49e7512632eb6

COCOAPODS: 1.11.3
COCOAPODS: 1.11.2
7 changes: 7 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import { Logger } from './plugins/Logger';
// @ts-ignore
import { AmplitudeSessionPlugin } from '@segment/analytics-react-native-plugin-amplitude-session';

//@ts-ignore
// import { AdvertisingIdPlugin } from '@segment/analytics-react-native-plugin-advertising-id';

const segmentClient = createClient({
writeKey: 'WRITE_KEY',
trackAppLifecycleEvents: true,
Expand All @@ -59,6 +62,10 @@ segmentClient.add({ plugin: LoggerPlugin });

segmentClient.add({ plugin: new AmplitudeSessionPlugin() });

// segmentClient.add({
// plugin: new AdvertisingIdPlugin(),
// });

const MainStack = createStackNavigator();
const RootStack = createStackNavigator();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1))
connection.project.dir=../../../example/android
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
java.home=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
Expand Down
1 change: 1 addition & 0 deletions packages/core/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ buildscript {
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'


def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AnalyticsReactNative_' + name]
}
Expand Down
47 changes: 47 additions & 0 deletions packages/core/android/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"project_info": {
"project_number": "169668264691",
"firebase_url": "https://segment-rn-analytics-tes-758c9.firebaseio.com",
"project_id": "segment-rn-analytics-tes-758c9",
"storage_bucket": "segment-rn-analytics-tes-758c9.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:169668264691:android:3c64b2cb29f7ff3516ed86",
"android_client_info": {
"package_name": "com.segmentanalyticsreactnative"
}
},
"oauth_client": [
{
"client_id": "169668264691-rv2engndk74jatm8t6v56bqi8dmavd16.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBo2zvlurBAZvKFyFFMf45Nd2FuBGjLn1A"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "169668264691-rv2engndk74jatm8t6v56bqi8dmavd16.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "169668264691-98m0t8lofv1nja1ki1hvi8j0heb5hesa.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "org.reactjs.native.AnalyticsReactNativeExample"
}
}
]
}
}
}
],
"configuration_version": "1"
}
Empty file.
Loading