Skip to content
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
Expand Up @@ -58,7 +58,6 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequiresApi(api = Build.VERSION_CODES.N)
Expand Down Expand Up @@ -632,7 +631,7 @@ private void setupEmailRecyclerView() {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
emailsRecyclerView.setLayoutManager(linearLayoutManager);
emailsRecyclerViewAdapter = new SubscriptionRecyclerViewAdapter(context, emailArrayList, value -> {
String email = ((IEmailSubscription)value).getEmail();
String email = ((DummySubscription)value).getId();
OneSignal.getUser().removeEmailSubscription(email);
emailArrayList.remove(value);
refreshEmailRecyclerView();
Expand All @@ -658,7 +657,7 @@ private void setupSMSRecyclerView() {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
smssRecyclerView.setLayoutManager(linearLayoutManager);
smssRecyclerViewAdapter = new SubscriptionRecyclerViewAdapter(context, smsArrayList, value -> {
String number = ((ISmsSubscription)value).getNumber();
String number = ((DummySubscription)value).getId();
OneSignal.getUser().removeSmsSubscription(number);
smsArrayList.remove(value);
refreshSMSRecyclerView();
Expand Down
320 changes: 320 additions & 0 deletions MIGRATION_GUIDE.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface IOneSignal {
* The user manager for accessing user-scoped
* management.
*/
val user: IUserManager
val User: IUserManager

/**
* The session manager for accessing session-scoped management.
Expand Down Expand Up @@ -85,7 +85,7 @@ interface IOneSignal {

/**
* Login to OneSignal under the user identified by the [externalId] provided. The act of
* logging a user into the OneSignal SDK will switch the [user] context to that specific user.
* logging a user into the OneSignal SDK will switch the [User] context to that specific user.
*
* * If the [externalId] exists the user will be retrieved and the context set from that
* user information. If operations have already been performed under a guest user, they
Expand All @@ -108,7 +108,7 @@ interface IOneSignal {
suspend fun login(externalId: String) = login(externalId, null)

/**
* Logout the user previously logged in via [login]. The [user] property now references
* Logout the user previously logged in via [login]. The [User] property now references
* a new device-scoped user. A device-scoped user has no user identity that can later
* be retrieved, except through this device as long as the app remains installed and the app
* data is not cleared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ object OneSignal {
* called.
*/
@JvmStatic
val user: IUserManager
get() = oneSignal.user
val User: IUserManager
get() = oneSignal.User

/**
* The session manager for accessing session-scoped management. Initialized only after [initWithContext]
Expand Down Expand Up @@ -128,7 +128,7 @@ object OneSignal {

/**
* Login to OneSignal under the user identified by the [externalId] provided. The act of
* logging a user into the OneSignal SDK will switch the [user] context to that specific user.
* logging a user into the OneSignal SDK will switch the [User] context to that specific user.
*
* * If the [externalId] exists the user will be retrieved and the context set from that
* user information. If operations have already been performed under a guest user, they
Expand All @@ -149,7 +149,7 @@ object OneSignal {

/**
* Login to OneSignal under the user identified by the [externalId] provided. The act of
* logging a user into the OneSignal SDK will switch the [user] context to that specific user.
* logging a user into the OneSignal SDK will switch the [User] context to that specific user.
*
* * If the [externalId] exists the user will be retrieved and the context set from that
* user information. If operations have already been performed under a guest user, they
Expand All @@ -172,7 +172,7 @@ object OneSignal {
suspend fun login(externalId: String, jwtBearerToken: String? = null) = oneSignal.login(externalId, jwtBearerToken)

/**
* Logout the user previously logged in via [login]. The [user] property now references
* Logout the user previously logged in via [login]. The [User] property now references
* a new device-scoped user. A device-scoped user has no user identity that can later
* be retrieved, except through this device as long as the app remains installed and the app
* data is not cleared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ object AndroidUtils {
return hasFlag
}

fun getAppVersion(context: Context): String? {
val appVersion: Int? =
try {
context.packageManager.getPackageInfo(context.packageName, 0).versionCode
} catch (e: PackageManager.NameNotFoundException) {
null
}

return appVersion?.toString()
}

fun getManifestMeta(context: Context, metaName: String?): String? {
val bundle = getManifestMetaBundle(context)
return bundle?.getString(metaName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal class OneSignalImp : IOneSignal, IServiceProvider {
override val notifications: INotificationsManager get() = if (isInitialized) _notifications!! else throw Exception("Must call 'initWithContext' before use")
override val location: ILocationManager get() = if (isInitialized) _location!! else throw Exception("Must call 'initWithContext' before use")
override val inAppMessages: IInAppMessagesManager get() = if (isInitialized) _iam!! else throw Exception("Must call 'initWithContext' before use")
override val user: IUserManager get() = if (isInitialized) _user!! else throw Exception("Must call 'initWithContext' before use")
override val User: IUserManager get() = if (isInitialized) _user!! else throw Exception("Must call 'initWithContext' before use")

// Services required by this class
private var _user: IUserManager? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ class SubscriptionObject(
val deviceOS: String? = null,
val rooted: Boolean? = null,
val netType: Int? = null,
val carrier: String? = null
val carrier: String? = null,
val appVersion: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object JSONConverter {
it.safeString("device_model"),
it.safeString("device_os"),
it.safeBool("rooted"),
it.safeInt("test_type"),
it.safeInt("net_type"),
it.safeString("carrier"),
it.safeString("app_version")
)
}
Expand Down Expand Up @@ -100,5 +101,6 @@ object JSONConverter {
.putSafe("rooted", subscription.rooted)
.putSafe("net_type", subscription.netType)
.putSafe("carrier", subscription.carrier)
.putSafe("app_version", subscription.appVersion)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.onesignal.user.internal.operations.impl.executors

import android.os.Build
import com.onesignal.common.AndroidUtils
import com.onesignal.common.DeviceUtils
import com.onesignal.common.NetworkUtils
import com.onesignal.common.OneSignalUtils
Expand Down Expand Up @@ -209,7 +210,8 @@ internal class LoginUserOperationExecutor(
Build.VERSION.RELEASE,
RootToolsInternalMethods.isRooted,
DeviceUtils.getNetType(_application.appContext),
DeviceUtils.getCarrierName(_application.appContext)
DeviceUtils.getCarrierName(_application.appContext),
AndroidUtils.getAppVersion(_application.appContext)
)

return mutableSubscriptions
Expand All @@ -229,7 +231,8 @@ internal class LoginUserOperationExecutor(
subscriptions[operation.subscriptionId]!!.deviceOS,
subscriptions[operation.subscriptionId]!!.rooted,
subscriptions[operation.subscriptionId]!!.netType,
subscriptions[operation.subscriptionId]!!.carrier
subscriptions[operation.subscriptionId]!!.carrier,
subscriptions[operation.subscriptionId]!!.appVersion
)
}
// TODO: Is it possible for the Create to be after the Update?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.onesignal.user.internal.operations.impl.executors

import android.os.Build
import com.onesignal.common.AndroidUtils
import com.onesignal.common.DeviceUtils
import com.onesignal.common.NetworkUtils
import com.onesignal.common.OneSignalUtils
Expand Down Expand Up @@ -82,7 +83,8 @@ internal class SubscriptionOperationExecutor(
Build.VERSION.RELEASE,
RootToolsInternalMethods.isRooted,
DeviceUtils.getNetType(_applicationService.appContext),
DeviceUtils.getCarrierName(_applicationService.appContext)
DeviceUtils.getCarrierName(_applicationService.appContext),
AndroidUtils.getAppVersion(_applicationService.appContext)
)

val backendSubscriptionId = _subscriptionBackend.createSubscription(
Expand Down Expand Up @@ -134,7 +136,8 @@ internal class SubscriptionOperationExecutor(
Build.VERSION.RELEASE,
RootToolsInternalMethods.isRooted,
DeviceUtils.getNetType(_applicationService.appContext),
DeviceUtils.getCarrierName(_applicationService.appContext)
DeviceUtils.getCarrierName(_applicationService.appContext),
AndroidUtils.getAppVersion(_applicationService.appContext)
)

_subscriptionBackend.updateSubscription(lastOperation.appId, lastOperation.subscriptionId, subscription)
Expand Down