[🐛] Unable to unregister for push notifications on Android
Issue
For a project that is ejected from expo, with the latest react-native-firebase packages installed, running on physical device, calls to messaging().unregisterDeviceForRemoteMessages() are neither succeeding nor throwing errors. Subsequent queries of messaging().isDeviceRegisteredForRemoteMessages indicate that the device is still registered for messages. The device still receives push notifications. There IS an error that occurs in the background on call to unregister but it is unclear how it is connected. Here is the code for the call-site:
try {
console.log('firebase - unregister initiating');
await messaging().unregisterDeviceForRemoteMessages();
let reg = await messaging().isDeviceRegisteredForRemoteMessages;
console.log("firebase - unregister finished with is registered ", reg);
} catch(err) {
console.log("Unregister failed firebase: ", err);
}
Here is the background exception I see that occurs after the unregister call (does not trigger the exception catch):
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: Error inserting flex_time=2442000 job_id=-1 period=4885000 source=16 requires_charging=0 preferred_network_type=1 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 required_idleness_state=0 service_kind=0 source_version=203019000 persistence_level=1 preferred_charging_state=1 required_network_type=0 runtime=1599906943472 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at arlu.a(:com.google.android.gms@[email protected] (120400-326531024):122)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at arkr.a(:com.google.android.gms@[email protected] (120400-326531024):183)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at arkr.a(:com.google.android.gms@[email protected] (120400-326531024):22)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at arkr.a(:com.google.android.gms@[email protected] (120400-326531024):178)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at argu.run(:com.google.android.gms@[email protected] (120400-326531024):9)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at stf.b(:com.google.android.gms@[email protected] (120400-326531024):12)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at stf.run(:com.google.android.gms@[email protected] (120400-326531024):7)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at szg.run(:com.google.android.gms@[email protected] (120400-326531024):0)
09-12 03:35:43.474 19203 25435 E SQLiteDatabase: at java.lang.Thread.run(Thread.java:919)
Here is the result of the subsequent query for whether the device is registered for notifications:
09-12 03:35:43.627 23684 25652 I ReactNativeJS: 'firebase - Unregister finished with is registered ', true
Project Files
package.json
Click To Expand
{
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "~10.0.6",
"@react-native-community/datetimepicker": "2.4.0",
"@react-native-community/masked-view": "0.1.10",
"@react-native-community/netinfo": "^5.9.6",
"@react-native-community/slider": "3.0.0",
"@react-native-firebase/analytics": "^7.6.1",
"@react-native-firebase/app": "^8.4.1",
"@react-native-firebase/auth": "^9.1.2",
"@react-native-firebase/firestore": "^7.7.0",
"@react-native-firebase/messaging": "^7.8.4",
"@react-native-firebase/storage": "^7.4.2",
"@react-navigation/bottom-tabs": "^5.0.0",
"@react-navigation/native": "^5.0.0",
"@react-navigation/stack": "^5.0.0",
"@react-navigation/web": "~1.0.0-alpha.9",
"@reduxjs/toolkit": "^1.4.0",
"email-validator": "^2.0.4",
"expo": "^38.0.9",
"expo-application": "~2.2.1",
"expo-asset": "~8.1.7",
"expo-auth-session": "~1.4.0",
"expo-av": "~8.2.1",
"expo-cli": "^3.21.5",
"expo-constants": "~9.1.1",
"expo-font": "~8.2.1",
"expo-intent-launcher": "~8.2.1",
"expo-linear-gradient": "~8.2.1",
"expo-linking": "^1.0.3",
"expo-localization": "~8.2.1",
"expo-splash-screen": "^0.5.0",
"expo-status-bar": "^1.0.2",
"expo-updates": "~0.2.10",
"expo-video-player": "^1.6.0",
"expo-web-browser": "~8.3.1",
"global": "^4.4.0",
"is-url": "^1.2.4",
"moment": "^2.26.0",
"moment-timezone": "^0.5.31",
"query-string": "^6.13.1",
"react": "~16.11.0",
"react-dom": "16.11.0",
"react-native": "~0.62.2",
"react-native-app-auth": "^6.0.0",
"react-native-base64": "^0.0.2",
"react-native-elements": "^2.0.0",
"react-native-expo-viewport-units": "^0.0.8",
"react-native-gesture-handler": "~1.6.0",
"react-native-google-appauth": "^1.0.5",
"react-native-reanimated": "~1.9.0",
"react-native-render-html": "^4.2.0",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "~2.9.0",
"react-native-svg": "12.1.0",
"react-native-svg-transformer": "^0.14.3",
"react-native-unimodules": "~0.10.1",
"react-native-web": "~0.11.7",
"react-native-webview": "9.4.0",
"react-redux": "^7.2.1",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-persist-expo-securestore": "^2.0.0",
"sentry-expo": "^2.1.2"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-jest": "~25.2.6",
"babel-preset-expo": "^8.2.3",
"jest": "~25.2.6",
"jest-expo": "^38.0.0",
"metro-config": "^0.59.0",
"node-fetch": "^2.6.0",
"react-test-renderer": "~16.11.0",
"redux-devtools": "^3.6.1",
"rimraf": "^3.0.2"
},
"private": true
}
android/build.gradle
Click To Expand
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.3'
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
android/app/build.gradle
Click To Expand
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation. If none specified and
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
enableHermes: false
]
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId 'gg.cloud9.app.android'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 8
versionName "1.0.1"
manifestPlaceholders = [appAuthRedirectScheme: 'com.redirectScheme.com']
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file(String.valueOf(System.getenv("C9_ANDROID_KEYSTORE_DEBUG")))
storePassword System.getenv("C9_ANDROID_STORE_PASS_DEBUG")
keyAlias System.getenv("C9_ANDROID_KEY_ALIAS_DEBUG")
keyPassword System.getenv("C9_ANDROID_KEY_PASS_DEBUG")
}
release {
storeFile file(String.valueOf(System.getenv("C9_ANDROID_KEYSTORE")))
storePassword System.getenv("C9_ANDROID_STORE_PASS")
keyAlias System.getenv("C9_ANDROID_KEY_ALIAS")
keyPassword System.getenv("C9_ANDROID_KEY_PASS")
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
packagingOptions {
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
addUnimodulesDependencies()
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
android/settings.gradle:
Click to Expand
rootProject.name = 'XXXXXXX'
apply from: '../node_modules/react-native-unimodules/gradle.groovy'
includeUnimodulesProjects()
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)
include ':app'
AndroidManifest.xml:
Click to Expand
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="XXXXXXXXXX">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_CALENDAR"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme">
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="YOUR-APP-URL-HERE"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="YOUR-APP-SDK-VERSION-HERE"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_notification" />
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="XXXXXXXX"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
</application>
</manifest>
Environment
Click To Expand
react-native info output:
System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 1.35 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.0.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.12.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.7.5 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 21, 23, 26, 27, 28, 29, 30
Build Tools: 27.0.3, 28.0.3, 29.0.2, 30.0.1, 30.0.2
Android NDK: Not Found
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 11.7/11E801a - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_131 - /usr/bin/javac
Python: 2.7.15 - /usr/local/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: ~16.11.0 => 16.11.0
react-native: ~0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
- Platform that you're experiencing the issue on:
- [ ] iOS
- [x] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
react-native-firebaseversion you're using that has this issue:^8.4.1
Firebasemodule(s) you're using that has the issue:react-native-firebase/messaging:^7.8.4
- Are you using
TypeScript?N
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
Strange. I think with Android (and that's a java stack, so this must be android) the app is always registered for remote notifications. This would be more of an iOS bit of functionality if I understand correctly.
The API for register has an iOS-specific wording: https://rnfirebase.io/reference/messaging#registerDeviceForRemoteMessages
Indeed, on android it just returns:
https://github.com/invertase/react-native-firebase/blob/9097f8e794f161f0c46bf1d54ae1e43386fbbb2c/packages/messaging/lib/index.js#L256-L265
So if your goal is to unregister for remote notifications on android, I do not think it is possible. In fact the APIs do not seem to exist in the underlying library:
https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessaging#public-method-summary
https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService#public-method-summary
So I assert the stack trace is unrelated, and is just some Android GMS services bookkeeping
I believe the only thing to do is to alter the associated notification channel settings such that they are silent (if you are sending notification payloads) or use the unsubscription listeners returned from onMessage
https://github.com/invertase/react-native-firebase/blob/9097f8e794f161f0c46bf1d54ae1e43386fbbb2c/packages/messaging/lib/index.js#L169
and/or alter the logic in any listener set to setBackgroundMessageHandler such that if you no longer wish to handle messages it discards them
We can re-open if my analysis is wrong - I could be wrong! - but it will need links to the APIs in the underlying SDKs that I'm possibly misunderstanding
Ah thanks for the follow-up! Sounds like misunderstanding on my part - I'll look into channel subscription on my end.
I ended up unregistering for messages on Android by using messaging().deleteToken(). I reregister by using messaging().getToken()