Skip to content

Commit eb7f1e4

Browse files
committed
Add sample OneSignal Android SDK
0 parents  commit eb7f1e4

37 files changed

+1013
-0
lines changed

.gitignore

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/android,androidstudio,kotlin,firebase
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=android,androidstudio,kotlin,firebase
4+
5+
### Android ###
6+
# Gradle files
7+
.gradle/
8+
build/
9+
10+
# Local configuration file (sdk path, etc)
11+
local.properties
12+
13+
# Log/OS Files
14+
*.log
15+
16+
# Android Studio generated files and folders
17+
captures/
18+
.externalNativeBuild/
19+
.cxx/
20+
*.apk
21+
output.json
22+
23+
# IntelliJ
24+
*.iml
25+
.idea/
26+
misc.xml
27+
deploymentTargetDropDown.xml
28+
render.experimental.xml
29+
30+
# Keystore files
31+
*.jks
32+
*.keystore
33+
34+
# Google Services (e.g. APIs or Firebase)
35+
google-services.json
36+
37+
# Android Profiling
38+
*.hprof
39+
40+
### Android Patch ###
41+
gen-external-apklibs
42+
43+
# Replacement of .externalNativeBuild directories introduced
44+
# with Android Studio 3.5.
45+
46+
### Firebase ###
47+
.idea
48+
**/node_modules/*
49+
**/.firebaserc
50+
51+
### Firebase Patch ###
52+
.runtimeconfig.json
53+
.firebase/
54+
55+
### Kotlin ###
56+
# Compiled class file
57+
*.class
58+
59+
# Log file
60+
61+
# BlueJ files
62+
*.ctxt
63+
64+
# Mobile Tools for Java (J2ME)
65+
.mtj.tmp/
66+
67+
# Package Files #
68+
*.jar
69+
*.war
70+
*.nar
71+
*.ear
72+
*.zip
73+
*.tar.gz
74+
*.rar
75+
76+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
77+
hs_err_pid*
78+
replay_pid*
79+
80+
### AndroidStudio ###
81+
# Covers files to be ignored for android development using Android Studio.
82+
83+
# Built application files
84+
*.ap_
85+
*.aab
86+
87+
# Files for the ART/Dalvik VM
88+
*.dex
89+
90+
# Java class files
91+
92+
# Generated files
93+
bin/
94+
gen/
95+
out/
96+
97+
# Gradle files
98+
.gradle
99+
100+
# Signing files
101+
.signing/
102+
103+
# Local configuration file (sdk path, etc)
104+
105+
# Proguard folder generated by Eclipse
106+
proguard/
107+
108+
# Log Files
109+
110+
# Android Studio
111+
/*/build/
112+
/*/local.properties
113+
/*/out
114+
/*/*/build
115+
/*/*/production
116+
.navigation/
117+
*.ipr
118+
*~
119+
*.swp
120+
121+
# Keystore files
122+
123+
# Google Services (e.g. APIs or Firebase)
124+
# google-services.json
125+
126+
# Android Patch
127+
128+
# External native build folder generated in Android Studio 2.2 and later
129+
.externalNativeBuild
130+
131+
# NDK
132+
obj/
133+
134+
# IntelliJ IDEA
135+
*.iws
136+
/out/
137+
138+
# User-specific configurations
139+
.idea/
140+
.idea/caches/
141+
.idea/libraries/
142+
.idea/shelf/
143+
.idea/workspace.xml
144+
.idea/tasks.xml
145+
.idea/.name
146+
.idea/compiler.xml
147+
.idea/copyright/profiles_settings.xml
148+
.idea/encodings.xml
149+
.idea/misc.xml
150+
.idea/modules.xml
151+
.idea/scopes/scope_settings.xml
152+
.idea/dictionaries
153+
.idea/vcs.xml
154+
.idea/jsLibraryMappings.xml
155+
.idea/datasources.xml
156+
.idea/dataSources.ids
157+
.idea/sqlDataSources.xml
158+
.idea/dynamic.xml
159+
.idea/uiDesigner.xml
160+
.idea/assetWizardSettings.xml
161+
.idea/gradle.xml
162+
.idea/jarRepositories.xml
163+
.idea/navEditor.xml
164+
165+
# Legacy Eclipse project files
166+
.classpath
167+
.project
168+
.cproject
169+
.settings/
170+
171+
# Mobile Tools for Java (J2ME)
172+
173+
# Package Files #
174+
175+
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
176+
177+
## Plugin-specific files:
178+
179+
# mpeltonen/sbt-idea plugin
180+
.idea_modules/
181+
182+
# JIRA plugin
183+
atlassian-ide-plugin.xml
184+
185+
# Mongo Explorer plugin
186+
.idea/mongoSettings.xml
187+
188+
# Crashlytics plugin (for Android Studio and IntelliJ)
189+
com_crashlytics_export_strings.xml
190+
crashlytics.properties
191+
crashlytics-build.properties
192+
fabric.properties
193+
194+
### AndroidStudio Patch ###
195+
196+
!/gradle/wrapper/gradle-wrapper.jar
197+
198+
# End of https://www.toptal.com/developers/gitignore/api/android,androidstudio,kotlin,firebase

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'com.google.gms.google-services'
5+
}
6+
7+
android {
8+
compileSdk 32
9+
10+
defaultConfig {
11+
applicationId "dev.lizarraga.onesignal"
12+
minSdk 21
13+
targetSdk 32
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
kotlinOptions {
31+
jvmTarget = '1.8'
32+
}
33+
}
34+
35+
dependencies {
36+
implementation 'androidx.core:core-ktx:1.7.0'
37+
implementation 'androidx.appcompat:appcompat:1.4.1'
38+
implementation 'com.google.android.material:material:1.6.0'
39+
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
40+
41+
implementation platform('com.google.firebase:firebase-bom:30.0.0')
42+
implementation 'com.google.firebase:firebase-analytics-ktx'
43+
44+
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
45+
46+
testImplementation 'junit:junit:4.13.2'
47+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
48+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
49+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.lizarraga.onesignal
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("dev.lizarraga.onesignal", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="dev.lizarraga.onesignal">
5+
6+
<application
7+
android:name=".OneSignalApplication"
8+
android:allowBackup="true"
9+
android:dataExtractionRules="@xml/data_extraction_rules"
10+
android:fullBackupContent="@xml/backup_rules"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/Theme.Kotlin_AndroidSDK"
16+
tools:targetApi="31">
17+
<activity
18+
android:name=".MainActivity"
19+
android:exported="true">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
26+
</application>
27+
28+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.lizarraga.onesignal
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
6+
class MainActivity : AppCompatActivity() {
7+
override fun onCreate(savedInstanceState: Bundle?) {
8+
super.onCreate(savedInstanceState)
9+
setContentView(R.layout.activity_main)
10+
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.lizarraga.onesignal
2+
3+
import android.app.Application
4+
import com.onesignal.OneSignal
5+
6+
class OneSignalApplication: Application() {
7+
8+
private val ONESIGNAL_APP_ID = "YOUR_APP_ID_HERE"
9+
10+
override fun onCreate() {
11+
super.onCreate()
12+
13+
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE)
14+
15+
OneSignal.initWithContext(this)
16+
OneSignal.setAppId(ONESIGNAL_APP_ID)
17+
}
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
8+
<aapt:attr name="android:fillColor">
9+
<gradient
10+
android:endX="85.84757"
11+
android:endY="92.4963"
12+
android:startX="42.9492"
13+
android:startY="49.59793"
14+
android:type="linear">
15+
<item
16+
android:color="#44000000"
17+
android:offset="0.0" />
18+
<item
19+
android:color="#00000000"
20+
android:offset="1.0" />
21+
</gradient>
22+
</aapt:attr>
23+
</path>
24+
<path
25+
android:fillColor="#FFFFFF"
26+
android:fillType="nonZero"
27+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
28+
android:strokeWidth="1"
29+
android:strokeColor="#00000000" />
30+
</vector>

0 commit comments

Comments
 (0)