diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/NotificationAPI.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/NotificationAPI.kt index a12c851e..d6b85d66 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/NotificationAPI.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/NotificationAPI.kt @@ -16,7 +16,6 @@ interface NotificationAPI { @DELETE("user/notifications/tokens/android/{token}/") suspend fun deleteNotificationToken( - @Header("Authorization") bearerToken: String, @Path("token") token: String, ): Response } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/fragments/PreferenceFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/fragments/PreferenceFragment.kt index 36801dec..f331ef6e 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/fragments/PreferenceFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/fragments/PreferenceFragment.kt @@ -24,7 +24,7 @@ import com.pennapps.labs.pennmobile.R import com.pennapps.labs.pennmobile.components.dialog.CustomAlertDialogue import com.pennapps.labs.pennmobile.gsr.fragments.PottruckFragment import com.pennapps.labs.pennmobile.home.fragments.NewsFragment -import com.pennapps.labs.pennmobile.more.viewmodels.PreferencesViewModel +import com.pennapps.labs.pennmobile.more.viewmodels.PreferenceViewModel import com.pennapps.labs.pennmobile.showSneakerToast import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -36,7 +36,7 @@ class PreferenceFragment : PreferenceFragmentCompat() { private lateinit var mContext: Context private lateinit var mActivity: MainActivity private lateinit var toolbar: Toolbar - private val preferencesViewModel: PreferencesViewModel by viewModels() + private val preferenceViewModel: PreferenceViewModel by viewModels() override fun onAttach(context: Context) { super.onAttach(context) @@ -275,14 +275,13 @@ class PreferenceFragment : PreferenceFragmentCompat() { } private fun deleteNotifToken(sp: SharedPreferences) { - val bearerToken = "Bearer " + sp.getString(getString(R.string.access_token), "").toString() val notifToken = sp.getString(getString(R.string.notification_token), "").toString() val mNotificationAPI = MainActivity.notificationAPIInstance Log.i("Notification Token", notifToken) lifecycleScope.launch(Dispatchers.IO) { try { - preferencesViewModel.deleteTokenResponse(mNotificationAPI, bearerToken, notifToken) + preferenceViewModel.deleteTokenResponse(mNotificationAPI, notifToken) } catch (e: Exception) { e.printStackTrace() } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/viewmodels/PreferencesViewModel.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/viewmodels/PreferenceViewModel.kt similarity index 88% rename from PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/viewmodels/PreferencesViewModel.kt rename to PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/viewmodels/PreferenceViewModel.kt index 591fab4d..bb7b366b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/viewmodels/PreferencesViewModel.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more/viewmodels/PreferenceViewModel.kt @@ -6,14 +6,13 @@ import com.pennapps.labs.pennmobile.api.NotificationAPI // Currently only implemented the notification logic, other network logistics to be implemented -class PreferencesViewModel : ViewModel() { +class PreferenceViewModel : ViewModel() { suspend fun deleteTokenResponse( mNotificationAPI: NotificationAPI, - bearerToken: String, notifToken: String, ) { try { - val response = mNotificationAPI.deleteNotificationToken(bearerToken, notifToken) + val response = mNotificationAPI.deleteNotificationToken(notifToken) if (response.isSuccessful) { Log.i("Notification Token", "Successfully deleted token") } else {