Skip to content

Commit 618b259

Browse files
abdulraqeeb33AR Abdul Azeeznan-lifadi-georgecursoragent
committed
chore: Updating the example app (#2543)
Co-authored-by: AR Abdul Azeez <abdul@onesignal.com> Co-authored-by: Nan <nan@onesignal.com> Co-authored-by: Fadi George <fadii925@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 857525e commit 618b259

136 files changed

Lines changed: 6555 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"agcgw":{
3+
"backurl":"connect-dre.hispace.hicloud.com",
4+
"url":"connect-dre.dbankcloud.cn",
5+
"websocketbackurl":"connect-ws-dre.hispace.dbankcloud.com",
6+
"websocketurl":"connect-ws-dre.hispace.dbankcloud.cn"
7+
},
8+
"agcgw_all":{
9+
"CN":"connect-drcn.dbankcloud.cn",
10+
"CN_back":"connect-drcn.hispace.hicloud.com",
11+
"DE":"connect-dre.dbankcloud.cn",
12+
"DE_back":"connect-dre.hispace.hicloud.com",
13+
"RU":"connect-drru.hispace.dbankcloud.ru",
14+
"RU_back":"connect-drru.hispace.dbankcloud.cn",
15+
"SG":"connect-dra.dbankcloud.cn",
16+
"SG_back":"connect-dra.hispace.hicloud.com"
17+
},
18+
"websocketgw_all":{
19+
"CN":"connect-ws-drcn.hispace.dbankcloud.cn",
20+
"CN_back":"connect-ws-drcn.hispace.dbankcloud.com",
21+
"DE":"connect-ws-dre.hispace.dbankcloud.cn",
22+
"DE_back":"connect-ws-dre.hispace.dbankcloud.com",
23+
"RU":"connect-ws-drru.hispace.dbankcloud.ru",
24+
"RU_back":"connect-ws-drru.hispace.dbankcloud.cn",
25+
"SG":"connect-ws-dra.hispace.dbankcloud.cn",
26+
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
27+
},
28+
"client":{
29+
"cp_id":"5190001000034239317",
30+
"product_id":"388421841221340564",
31+
"client_id":"1103097158011211392",
32+
"client_secret":"14843C60CAFDCFD5E50025C14864697AFF55886BCF00558E8C817F141E0B4704",
33+
"project_id":"388421841221340564",
34+
"app_id":"107780279",
35+
"api_key":"DAEDAN06wwm3fsiHbQaQzugegFDUc6lpsR9VZGRNoWEbjHpDphR5rSbobUr5/ohT1WlRTyIykjr4GzzEJ/jSxlziFmXF/8e56HAYiw==",
36+
"package_name":"com.onesignal.sdktest"
37+
},
38+
"oauth_client":{
39+
"client_id":"107780279",
40+
"client_type":1
41+
},
42+
"app_info":{
43+
"app_id":"107780279",
44+
"package_name":"com.onesignal.sdktest"
45+
},
46+
"service":{
47+
"analytics":{
48+
"collector_url":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
49+
"collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com",
50+
"collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn",
51+
"collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
52+
"collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
53+
"resource_id":"p1",
54+
"channel_id":""
55+
},
56+
"edukit":{
57+
"edu_url":"edukit.edu.cloud.huawei.com.cn",
58+
"dh_url":"edukit.edu.cloud.huawei.com.cn"
59+
},
60+
"search":{
61+
"url":"https://search-dre.cloud.huawei.com"
62+
},
63+
"cloudstorage":{
64+
"storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia",
65+
"storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru",
66+
"storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru",
67+
"storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu",
68+
"storage_url_de":"https://ops-dre.agcstorage.link",
69+
"storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn",
70+
"storage_url_sg":"https://ops-dra.agcstorage.link",
71+
"storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn",
72+
"storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn"
73+
},
74+
"ml":{
75+
"mlservice_url":"ml-api-dre.ai.dbankcloud.com,ml-api-dre.ai.dbankcloud.cn"
76+
}
77+
},
78+
"region":"DE",
79+
"configuration_version":"3.0",
80+
"appInfos":[
81+
{
82+
"package_name":"com.onesignal.sdktest",
83+
"client":{
84+
"app_id":"107780279"
85+
},
86+
"app_info":{
87+
"package_name":"com.onesignal.sdktest",
88+
"app_id":"107780279"
89+
},
90+
"oauth_client":{
91+
"client_type":1,
92+
"client_id":"107780279"
93+
}
94+
}
95+
]
96+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
plugins {
2+
id(Plugins.androidApplication)
3+
id(Plugins.kotlinAndroid)
4+
}
5+
6+
// Apply GMS or Huawei plugin based on build variant
7+
// Check at configuration time, not when task graph is ready
8+
val taskRequests = gradle.startParameter.taskRequests.toString().lowercase()
9+
if (taskRequests.contains("gms")) {
10+
apply(plugin = Plugins.googleServices)
11+
} else if (taskRequests.contains("huawei")) {
12+
apply(plugin = Plugins.huaweiAgconnect)
13+
}
14+
15+
// OneSignal SDK version - can be overridden via gradle property SDK_VERSION
16+
val sdkVersion: String = rootProject.findProperty("SDK_VERSION") as? String ?: Versions.oneSignalSdk
17+
18+
android {
19+
namespace = AppConfig.applicationId
20+
compileSdk = Versions.compileSdk
21+
22+
defaultConfig {
23+
minSdk = Versions.minSdk
24+
targetSdk = Versions.targetSdk
25+
versionCode = Versions.versionCode
26+
versionName = Versions.versionName
27+
multiDexEnabled = true
28+
29+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
30+
}
31+
32+
buildFeatures {
33+
compose = true
34+
}
35+
36+
composeOptions {
37+
kotlinCompilerExtensionVersion = Versions.composeCompiler
38+
}
39+
40+
flavorDimensions += "default"
41+
42+
productFlavors {
43+
create("gms") {
44+
dimension = "default"
45+
applicationId = AppConfig.applicationId
46+
}
47+
create("huawei") {
48+
dimension = "default"
49+
minSdk = Versions.minSdk
50+
applicationId = AppConfig.applicationId
51+
}
52+
}
53+
54+
buildTypes {
55+
release {
56+
isMinifyEnabled = false
57+
proguardFiles(
58+
getDefaultProguardFile("proguard-android-optimize.txt"),
59+
"proguard-rules.pro"
60+
)
61+
}
62+
debug {
63+
isDebuggable = true
64+
}
65+
create("profileable") {
66+
initWith(getByName("release"))
67+
isDebuggable = false
68+
isProfileable = true
69+
isMinifyEnabled = false
70+
signingConfig = signingConfigs.getByName("debug")
71+
matchingFallbacks += listOf("release")
72+
}
73+
}
74+
75+
kotlinOptions {
76+
jvmTarget = "1.8"
77+
}
78+
79+
compileOptions {
80+
sourceCompatibility = JavaVersion.VERSION_1_8
81+
targetCompatibility = JavaVersion.VERSION_1_8
82+
}
83+
84+
packaging {
85+
resources {
86+
excludes += "androidsupportmultidexversion.txt"
87+
}
88+
}
89+
}
90+
91+
dependencies {
92+
// Kotlin
93+
implementation(Dependencies.kotlinStdlib)
94+
implementation(Dependencies.coroutinesAndroid)
95+
96+
// AndroidX
97+
implementation(Dependencies.multidex)
98+
implementation(Dependencies.appcompat)
99+
implementation(Dependencies.coreKtx)
100+
101+
// Compose BOM
102+
implementation(platform(Dependencies.composeBom))
103+
implementation(Dependencies.composeUi)
104+
implementation(Dependencies.composeUiGraphics)
105+
implementation(Dependencies.composeUiToolingPreview)
106+
implementation(Dependencies.composeMaterial3)
107+
implementation(Dependencies.composeMaterialIcons)
108+
implementation(Dependencies.composeRuntime)
109+
implementation(Dependencies.composeRuntimeLivedata)
110+
debugImplementation(Dependencies.composeUiTooling)
111+
112+
// Activity & Lifecycle Compose
113+
implementation(Dependencies.activityCompose)
114+
implementation(Dependencies.lifecycleViewModelCompose)
115+
implementation(Dependencies.lifecycleRuntimeCompose)
116+
117+
// Lifecycle
118+
implementation(Dependencies.lifecycleViewModelKtx)
119+
implementation(Dependencies.lifecycleRuntimeKtx)
120+
121+
// Google Play Services
122+
implementation(Dependencies.playServicesLocation)
123+
124+
// OneSignal - Google Play Builds
125+
"gmsImplementation"("com.onesignal:OneSignal:$sdkVersion")
126+
127+
// OneSignal - Huawei Builds
128+
"huaweiImplementation"("com.onesignal:OneSignal:$sdkVersion") {
129+
exclude(group = "com.google.android.gms", module = "play-services-gcm")
130+
exclude(group = "com.google.android.gms", module = "play-services-analytics")
131+
exclude(group = "com.google.android.gms", module = "play-services-location")
132+
exclude(group = "com.google.firebase", module = "firebase-messaging")
133+
}
134+
"huaweiImplementation"(Dependencies.huaweiPush)
135+
"huaweiImplementation"(Dependencies.huaweiLocation)
136+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"project_info": {
3+
"project_number": "249481192614",
4+
"firebase_url": "https://onesignaltest-e7802.firebaseio.com",
5+
"project_id": "onesignaltest-e7802",
6+
"storage_bucket": "onesignaltest-e7802.appspot.com"
7+
},
8+
"client": [
9+
{
10+
"client_info": {
11+
"mobilesdk_app_id": "1:249481192614:android:9d39e24e24034b14",
12+
"android_client_info": {
13+
"package_name": "com.onesignal.sdktest"
14+
}
15+
},
16+
"oauth_client": [],
17+
"api_key": [
18+
{
19+
"current_key": "AIzaSyC2H_Z5NRhKVJsoG6dLwzSrH3aLNm7p3sw"
20+
}
21+
],
22+
"services": {
23+
"appinvite_service": {
24+
"other_platform_oauth_client": []
25+
}
26+
}
27+
}
28+
],
29+
"configuration_version": "1"
30+
}
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application
5+
android:name=".application.MainApplication">
6+
7+
<service
8+
android:name="com.onesignal.sdktest.notification.HmsMessageServiceAppLevel"
9+
android:exported="false">
10+
<intent-filter>
11+
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
12+
</intent-filter>
13+
</service>
14+
15+
</application>
16+
17+
</manifest>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.onesignal.sdktest.notification
2+
3+
import android.os.Bundle
4+
import android.util.Log
5+
import com.huawei.hms.push.HmsMessageService
6+
import com.huawei.hms.push.RemoteMessage
7+
import com.onesignal.notifications.bridges.OneSignalHmsEventBridge
8+
9+
/**
10+
* HMS Message Service for handling Huawei Push notifications.
11+
* This service forwards all push events to the OneSignal SDK.
12+
*
13+
* Note: This is the Huawei flavor-specific implementation.
14+
*/
15+
class HmsMessageServiceAppLevel : HmsMessageService() {
16+
17+
companion object {
18+
private const val TAG = "OneSignalHMS"
19+
}
20+
21+
/**
22+
* When an app calls the getToken method to apply for a token from the server,
23+
* if the server does not return the token during current method calling,
24+
* the server can return the token through this method later.
25+
* This method callback must be completed in 10 seconds.
26+
* Otherwise, you need to start a new Job for callback processing.
27+
*/
28+
override fun onNewToken(token: String, bundle: Bundle) {
29+
Log.d(TAG, "HmsMessageServiceAppLevel onNewToken refresh token: $token bundle: $bundle")
30+
31+
// Forward event on to OneSignal SDK
32+
OneSignalHmsEventBridge.onNewToken(this, token, bundle)
33+
}
34+
35+
@Deprecated("Deprecated in Java")
36+
override fun onNewToken(token: String) {
37+
Log.d(TAG, "HmsMessageServiceAppLevel onNewToken refresh token: $token")
38+
39+
// Forward event on to OneSignal SDK
40+
OneSignalHmsEventBridge.onNewToken(this, token)
41+
}
42+
43+
/**
44+
* This method is called in the following cases:
45+
* 1. "Data messages" - App process is alive when received.
46+
* 2. "Notification Message" - foreground_show = false and app is in focus
47+
* This method callback must be completed in 10 seconds.
48+
* Start a new Job if more time is needed.
49+
*/
50+
override fun onMessageReceived(message: RemoteMessage) {
51+
Log.d(TAG, "HMS onMessageReceived: $message")
52+
Log.d(TAG, "HMS onMessageReceived.ttl: ${message.ttl}")
53+
Log.d(TAG, "HMS onMessageReceived.data: ${message.data}")
54+
55+
message.notification?.let { notification ->
56+
Log.d(TAG, "HMS onMessageReceived.title: ${notification.title}")
57+
Log.d(TAG, "HMS onMessageReceived.body: ${notification.body}")
58+
Log.d(TAG, "HMS onMessageReceived.icon: ${notification.icon}")
59+
Log.d(TAG, "HMS onMessageReceived.color: ${notification.color}")
60+
Log.d(TAG, "HMS onMessageReceived.channelId: ${notification.channelId}")
61+
Log.d(TAG, "HMS onMessageReceived.imageURL: ${notification.imageUrl}")
62+
Log.d(TAG, "HMS onMessageReceived.tag: ${notification.tag}")
63+
}
64+
65+
// Forward event on to OneSignal SDK
66+
OneSignalHmsEventBridge.onMessageReceived(this, message)
67+
}
68+
}

0 commit comments

Comments
 (0)