Skip to content

Commit

Permalink
Merge pull request #1981 from OneSignal/user-model/main
Browse files Browse the repository at this point in the history
Merge user-model/main into main
  • Loading branch information
jinliu9508 authored Feb 6, 2024
2 parents 1d27d82 + d73bfc6 commit 4f2f7ad
Show file tree
Hide file tree
Showing 839 changed files with 46,231 additions and 55,789 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,10 @@ jobs:
working-directory: OneSignalSDK
run: |
./gradlew ktlintCheck --console=plain
- name: "[Test] Analyzing"
working-directory: OneSignalSDK
continue-on-error: true
run: |
./gradlew detekt --console=plain
- name: "[Test] SDK Unit Tests"
working-directory: OneSignalSDK
run: |
./gradlew unittest:testReleaseUnitTest --console=plain
./gradlew test --console=plain
- name: Unit tests results
if: failure()
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/set_response_time.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: npm install @octokit/action@6.0.6
- run: npm install @octokit/action
- uses: actions/github-script@v6
id: set-time
with:
Expand Down
82 changes: 54 additions & 28 deletions Examples/OneSignalDemo/app/agconnect-services.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,75 @@
{
"agcgw":{
"backurl":"connect-dre.dbankcloud.cn",
"url":"connect-dre.hispace.hicloud.com",
"websocketbackurl":"connect-ws-dre.hispace.dbankcloud.cn",
"websocketurl":"connect-ws-dre.hispace.dbankcloud.com"
"backurl":"connect-dre.hispace.hicloud.com",
"url":"connect-dre.dbankcloud.cn",
"websocketbackurl":"connect-ws-dre.hispace.dbankcloud.com",
"websocketurl":"connect-ws-dre.hispace.dbankcloud.cn"
},
"agcgw_all":{
"CN":"connect-drcn.hispace.hicloud.com",
"CN_back":"connect-drcn.dbankcloud.cn",
"DE":"connect-dre.hispace.hicloud.com",
"DE_back":"connect-dre.dbankcloud.cn",
"RU":"connect-drru.hispace.hicloud.com",
"RU_back":"connect-drru.dbankcloud.cn",
"SG":"connect-dra.hispace.hicloud.com",
"SG_back":"connect-dra.dbankcloud.cn"
"CN":"connect-drcn.dbankcloud.cn",
"CN_back":"connect-drcn.hispace.hicloud.com",
"DE":"connect-dre.dbankcloud.cn",
"DE_back":"connect-dre.hispace.hicloud.com",
"RU":"connect-drru.hispace.dbankcloud.ru",
"RU_back":"connect-drru.hispace.dbankcloud.cn",
"SG":"connect-dra.dbankcloud.cn",
"SG_back":"connect-dra.hispace.hicloud.com"
},
"websocketgw_all":{
"CN":"connect-ws-drcn.hispace.dbankcloud.cn",
"CN_back":"connect-ws-drcn.hispace.dbankcloud.com",
"DE":"connect-ws-dre.hispace.dbankcloud.cn",
"DE_back":"connect-ws-dre.hispace.dbankcloud.com",
"RU":"connect-ws-drru.hispace.dbankcloud.ru",
"RU_back":"connect-ws-drru.hispace.dbankcloud.cn",
"SG":"connect-ws-dra.hispace.dbankcloud.cn",
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
},
"client":{
"cp_id":"5190001000034239317",
"product_id":"9105385871709201822",
"client_id":"336482233541985344",
"client_secret":"5E30C748A012DE67BAF83E2C542A4AB694CCAA89F1D5E8FCEFA57E0F28A077FB",
"project_id":"9105385871709201822",
"app_id":"102009847",
"api_key":"CV68fkx9E2fU8Fv/v3zbuO8+rCjJ8w6QiMha7ZJUpIGTxs08n0/ddVXbOueUKBtxf3sD+ni8WPx27htLHhtse5eP5VrT",
"package_name":"com.onesignal.example"
"product_id":"388421841221340564",
"client_id":"1103097158011211392",
"client_secret":"14843C60CAFDCFD5E50025C14864697AFF55886BCF00558E8C817F141E0B4704",
"project_id":"388421841221340564",
"app_id":"107780279",
"api_key":"DAEDAN06wwm3fsiHbQaQzugegFDUc6lpsR9VZGRNoWEbjHpDphR5rSbobUr5/ohT1WlRTyIykjr4GzzEJ/jSxlziFmXF/8e56HAYiw==",
"package_name":"com.onesignal.sdktest"
},
"oauth_client":{
"client_id":"102009847",
"client_id":"107780279",
"client_type":1
},
"app_info":{
"app_id":"102009847",
"package_name":"com.onesignal.example"
"app_id":"107780279",
"package_name":"com.onesignal.sdktest"
},
"service":{
"analytics":{
"collector_url":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
"collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com",
"collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn",
"collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
"collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
"resource_id":"p1",
"channel_id":""
},
"edukit":{
"edu_url":"edukit.edu.cloud.huawei.com.cn",
"dh_url":"edukit.edu.cloud.huawei.com.cn"
},
"search":{
"url":"https://search-dre.cloud.huawei.com"
},
"cloudstorage":{
"storage_url":"https://ops-dre.agcstorage.link"
"storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia",
"storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru",
"storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru",
"storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu",
"storage_url_de":"https://ops-dre.agcstorage.link",
"storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn",
"storage_url_sg":"https://ops-dra.agcstorage.link",
"storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn",
"storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn"
},
"ml":{
"mlservice_url":"ml-api-dre.ai.dbankcloud.com,ml-api-dre.ai.dbankcloud.cn"
Expand All @@ -53,17 +79,17 @@
"configuration_version":"3.0",
"appInfos":[
{
"package_name":"com.onesignal.example",
"package_name":"com.onesignal.sdktest",
"client":{
"app_id":"102009847"
"app_id":"107780279"
},
"app_info":{
"package_name":"com.onesignal.example",
"app_id":"102009847"
"package_name":"com.onesignal.sdktest",
"app_id":"107780279"
},
"oauth_client":{
"client_type":1,
"client_id":"102009847"
"client_id":"107780279"
}
}
]
Expand Down
53 changes: 36 additions & 17 deletions Examples/OneSignalDemo/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 31
compileSdkVersion 33
defaultConfig {
minSdkVersion 19
targetSdkVersion 31
targetSdkVersion 33
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand All @@ -13,12 +15,16 @@ android {
flavorDimensions "default"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// signingConfigs {
// huawei {
// storeFile file('SdkTest.jks')
// keyAlias 'SdkTest'
// keyPassword ''
// storePassword ''
// v1SigningEnabled true
// v2SigningEnabled true
// }
// }

productFlavors {
gms {
Expand All @@ -27,8 +33,20 @@ android {
}
huawei {
dimension "default"
minSdkVersion 17
applicationId "com.onesignal.example"
minSdkVersion 19
applicationId "com.onesignal.sdktest"
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
// signingConfig null
// productFlavors.huawei.signingConfig signingConfigs.huawei
debuggable true
}
}

Expand All @@ -53,24 +71,25 @@ android {
}

dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.4.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'

implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'com.google.android.gms:play-services-location:21.0.0'

implementation 'com.github.bumptech.glide:glide:4.12.0'

/** START - Google Play Builds **/
gmsImplementation('com.onesignal:OneSignal:4.6.3')
gmsImplementation('com.onesignal:OneSignal:5.1.2')
/** END - Google Play Builds **/

/** START - Huawei Builds **/
// Omit Google / Firebase libraries for Huawei builds.
huaweiImplementation('com.onesignal:OneSignal:4.6.3') {
huaweiImplementation('com.onesignal:OneSignal:5.1.2') {
exclude group: 'com.google.android.gms', module: 'play-services-gcm'
exclude group: 'com.google.android.gms', module: 'play-services-analytics'
exclude group: 'com.google.android.gms', module: 'play-services-location'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.onesignal.sdktest.notification;

import android.os.Bundle;
import android.util.Log;

import com.huawei.hms.push.HmsMessageService;
import com.huawei.hms.push.RemoteMessage;
import com.onesignal.OneSignal;
import com.onesignal.OneSignalHmsEventBridge;
import com.onesignal.notifications.bridges.OneSignalHmsEventBridge;
import com.onesignal.sdktest.constant.Tag;

public class HmsMessageServiceAppLevel extends HmsMessageService {

Expand All @@ -19,19 +20,19 @@ public class HmsMessageServiceAppLevel extends HmsMessageService {
*/
@Override
public void onNewToken(String token, Bundle bundle) {
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HmsMessageServiceAppLevel onNewToken refresh token:" + token + " bundle: " + bundle);
Log.d(Tag.LOG_TAG, "HmsMessageServiceAppLevel onNewToken refresh token:" + token + " bundle: " + bundle);

// Forward event on to OneSignal SDK
OneSignalHmsEventBridge.onNewToken(this, token, bundle);
OneSignalHmsEventBridge.INSTANCE.onNewToken(this, token, bundle);
}

@Deprecated
@Override
public void onNewToken(String token) {
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HmsMessageServiceAppLevel onNewToken refresh token:" + token);
Log.d(Tag.LOG_TAG, "HmsMessageServiceAppLevel onNewToken refresh token:" + token);

// Forward event on to OneSignal SDK
OneSignalHmsEventBridge.onNewToken(this, token);
OneSignalHmsEventBridge.INSTANCE.onNewToken(this, token);
}

/**
Expand All @@ -44,18 +45,18 @@ public void onNewToken(String token) {
*/
@Override
public void onMessageReceived(RemoteMessage message) {
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived: " + message);
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.ttl:" + message.getTtl());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.data:" + message.getData());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.title: " + message.getNotification().getTitle());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.body: " + message.getNotification().getBody());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.icon: " + message.getNotification().getIcon());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.color: " + message.getNotification().getColor());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.channelId: " + message.getNotification().getChannelId());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.imageURL: " + message.getNotification().getImageUrl());
OneSignal.onesignalLog(OneSignal.LOG_LEVEL.DEBUG, "HMS onMessageReceived.tag: " + message.getNotification().getTag());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived: " + message);
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.ttl:" + message.getTtl());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.data:" + message.getData());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.title: " + message.getNotification().getTitle());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.body: " + message.getNotification().getBody());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.icon: " + message.getNotification().getIcon());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.color: " + message.getNotification().getColor());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.channelId: " + message.getNotification().getChannelId());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.imageURL: " + message.getNotification().getImageUrl());
Log.d(Tag.LOG_TAG, "HMS onMessageReceived.tag: " + message.getNotification().getTag());

// Forward event on to OneSignal SDK
OneSignalHmsEventBridge.onMessageReceived(this, message);
OneSignalHmsEventBridge.INSTANCE.onMessageReceived(this, message);
}
}
6 changes: 3 additions & 3 deletions Examples/OneSignalDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
</service>

<service
android:name="com.onesignal.ADMMessageHandlerJob"
android:name="com.onesignal.notifications.services.ADMMessageHandlerJob"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false" />

<!-- This is needed for devices with older ADM versions -->
<service
android:name="com.onesignal.ADMMessageHandler"
android:name="com.onesignal.notifications.services.ADMMessageHandler"
android:exported="false" />

<receiver
android:name="com.onesignal.ADMMessageHandler$Receiver"
android:name="com.onesignal.notifications.receivers.ADMMessageReceiver"
android:permission="com.amazon.device.messaging.permission.SEND"
android:exported="true">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.onesignal.sdktest.activity;

import android.os.Build;
import android.os.Bundle;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import com.onesignal.OneSignal;
import com.onesignal.sdktest.R;
import com.onesignal.sdktest.model.MainActivityViewModel;

@RequiresApi(api = Build.VERSION_CODES.N)
public class MainActivity extends AppCompatActivity {

private MainActivityViewModel viewModel;
Expand All @@ -18,9 +21,10 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main_activity_layout);

viewModel = new MainActivityViewModel();
OneSignal.addPermissionObserver(viewModel);
OneSignal.addSubscriptionObserver(viewModel);
OneSignal.addEmailSubscriptionObserver(viewModel);
OneSignal.getNotifications().addPermissionObserver(viewModel);
// TODO("STILL SUPPORT?")
// OneSignal.addSubscriptionObserver(viewModel);
// OneSignal.addEmailSubscriptionObserver(viewModel);
viewModel.onActivityCreated(this)
.setupInterfaceElements();
}
Expand All @@ -37,8 +41,8 @@ public void onBackPressed() {
protected void onResume() {
super.onResume();

boolean hasConsent = OneSignal.userProvidedPrivacyConsent();
boolean hasConsent = OneSignal.getConsentGiven();
if (hasConsent)
viewModel.setupSettingsLayout();
viewModel.setupLayout();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ private void populateInterfaceElements(final int position) {

if (Util.isBoolean(value))
value += " (bool)";
else if (Util.isNumeric(value))
value += " (num)";
else if (Util.isInteger(value))
value += " (int)";
else if (Util.isFloat(value))
value += " (float)";
else
value += " (str)";
pairValueTextView.setText(value);
Expand Down
Loading

0 comments on commit 4f2f7ad

Please sign in to comment.