Skip to content

[User Model] Pre-Beta Fixes #1730

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 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.onesignal.sdktest.notification;

import android.content.Context;
import android.util.Log;

import com.onesignal.debug.LogLevel;
import com.onesignal.debug.internal.logging.Logging;
import com.onesignal.notifications.IActionButton;
import com.onesignal.notifications.IMutableNotification;
import com.onesignal.notifications.INotification;
Expand All @@ -15,14 +14,13 @@ public class NotificationServiceExtension implements IRemoteNotificationReceived

@Override
public void remoteNotificationReceived(Context context, INotificationReceivedEvent notificationReceivedEvent) {
Logging.log(LogLevel.VERBOSE, "OSRemoteNotificationReceivedHandler fired!" +
" with OSNotificationReceived: " + notificationReceivedEvent.toString());
Log.v("MainApplication", "IRemoteNotificationReceivedHandler fired!" + " with INotificationReceivedEvent: " + notificationReceivedEvent.toString());

INotification notification = notificationReceivedEvent.getNotification();

if (notification.getActionButtons() != null) {
for (IActionButton button : notification.getActionButtons()) {
Logging.log(LogLevel.VERBOSE, "ActionButton: " + button.toString());
Log.v("MainApplication", "ActionButton: " + button.toString());
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package com.onesignal.common
import java.util.regex.Pattern

object OneSignalUtils {
@JvmStatic
var sdkType = "native"

@JvmStatic
val sdkVersion: String = "050000"
/**
* The version of this SDK.
*/
const val sdkVersion: String = "050000"

fun isValidEmail(email: String): Boolean {
if (email.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.onesignal.common

object OneSignalWrapper {
/**
* The type of the wrapper SDK.
*/
@JvmStatic
var sdkType: String? = null

/**
* The version of the wrapper SDK.
*/
@JvmStatic
val sdkVersion: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.net.TrafficStats
import android.os.Build
import com.onesignal.common.JSONUtils
import com.onesignal.common.OneSignalUtils
import com.onesignal.common.OneSignalWrapper
import com.onesignal.core.internal.config.ConfigModelStore
import com.onesignal.core.internal.http.HttpResponse
import com.onesignal.core.internal.http.IHttpClient
Expand Down Expand Up @@ -109,6 +110,11 @@ internal class HttpClient(
con.connectTimeout = timeout
con.readTimeout = timeout
con.setRequestProperty("SDK-Version", "onesignal/android/" + OneSignalUtils.sdkVersion)

if(OneSignalWrapper.sdkType != null && OneSignalWrapper.sdkVersion != null) {
con.setRequestProperty("SDK-Wrapper", "onesignal/${OneSignalWrapper.sdkType}/${OneSignalWrapper.sdkVersion}")
}

con.setRequestProperty("Accept", OS_ACCEPT_HEADER)

val subscriptionId = _configModelStore.model.pushSubscriptionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ object PreferenceOneSignalKeys {
/**
* (Long) The last time an IAM was dismissed, in unix time milliseconds.
*/
const val PREFS_OS_LAST_TIME_IAM_DISMISSED = "PREFS_OS_LAST_TIME_IAM_DISMISSED"
const val PREFS_OS_IAM_LAST_DISMISSED_TIME = "PREFS_OS_IAM_LAST_DISMISSED_TIME"

// Models
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ enum class LogLevel {
WARN,
INFO,
DEBUG,
VERBOSE
VERBOSE;

companion object {
@JvmStatic
fun fromInt(value: Int) : LogLevel {
return values()[value];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ package com.onesignal.inAppMessages
* being displayed.
*/
interface IInAppMessageAction {
/**
* UUID assigned by OneSignal for internal use.
* Package-private to track which element was tapped to report to the OneSignal dashboard.
*/
val clickId: String?

/**
* An optional click name entered defined by the app developer when creating the IAM
*/
Expand All @@ -26,11 +20,6 @@ interface IInAppMessageAction {
*/
val clickUrl: String?

/**
* UUID for the page in an IAM Carousel
*/
val pageId: String?

/**
* Determines if this was the first action taken on the in app message
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ interface INotificationsManager {
*
* @param id The android ID of the notification to be removed. See [INotification.androidNotificationId].
*/
suspend fun removeNotification(id: Int)
fun removeNotification(id: Int)

/**
* Cancels a group of OneSignal notifications with the provided group key. Grouping notifications
* is a OneSignal concept, there is no [android.app.NotificationManager] equivalent.
*
* @param group The group key which all notifications fall under will be removed. See [INotification.groupKey].
*/
suspend fun removeGroupedNotifications(group: String)
fun removeGroupedNotifications(group: String)

/**
* Removes all OneSignal notifications from the Notification Shade. If you just use
* [android.app.NotificationManager.cancelAll], OneSignal notifications will be restored when
* your app is restarted.
*/
suspend fun clearAllNotifications()
fun clearAllNotifications()

/**
* The [IPermissionChangedHandler.onPermissionChanged] method will be fired on the passed-in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ internal class MisconfiguredNotificationsManager : INotificationsManager {
get() = throw EXCEPTION

override suspend fun requestPermission(fallbackToSettings: Boolean): Boolean = throw EXCEPTION
override suspend fun removeNotification(id: Int) = throw EXCEPTION
override suspend fun removeGroupedNotifications(group: String) = throw EXCEPTION
override suspend fun clearAllNotifications() = throw EXCEPTION
override fun removeNotification(id: Int) = throw EXCEPTION
override fun removeGroupedNotifications(group: String) = throw EXCEPTION
override fun clearAllNotifications() = throw EXCEPTION
override fun addPermissionChangedHandler(handler: IPermissionChangedHandler) = throw EXCEPTION
override fun removePermissionChangedHandler(handler: IPermissionChangedHandler) = throw EXCEPTION
override fun setNotificationWillShowInForegroundHandler(handler: INotificationWillShowInForegroundHandler?) = throw EXCEPTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SessionModel : Model() {
* When this session started, in Unix time milliseconds.
*/
var startTime: Long
get() = getLongProperty(::startTime.name)
get() = getLongProperty(::startTime.name) { System.currentTimeMillis() }
set(value) { setLongProperty(::startTime.name, value) }

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class InAppMessageAction(json: JSONObject, promptFactory: IInAppMessage
* UUID assigned by OneSignal for internal use.
* Package-private to track which element was tapped to report to the OneSignal dashboard.
*/
override val clickId: String?
val clickId: String?

/**
* An optional click name entered defined by the app developer when creating the IAM
Expand All @@ -34,7 +34,7 @@ internal class InAppMessageAction(json: JSONObject, promptFactory: IInAppMessage
/**
* UUID for the page in an IAM Carousel
*/
override val pageId: String?
val pageId: String?

/**
* Outcome for action
Expand Down
Loading