Skip to content

Instantly share code, notes, and snippets.

@jeziellago
Last active March 2, 2023 02:35
Show Gist options
  • Save jeziellago/023b563a34186705ae4f72d370b746b0 to your computer and use it in GitHub Desktop.
Save jeziellago/023b563a34186705ae4f72d370b746b0 to your computer and use it in GitHub Desktop.
Send android push notification to app or open app from deeplink using ADB (Android Debug Bridge)
@jeziellago
Copy link
Author

jeziellago commented May 21, 2020

No root required 😎

It is possible to send FCM payloads via adb.

While it is true that the permission com.google.android.c2dm.permission.SEND is a problem, there's a workaround.

Gradle adds the FirebaseInstanceIdReceiver to the merged manifest. the workaround is to add your own copy to the manifest and override the permission using the tools:replace="android:permission" and android:permission="@null"

Add it on your debug AndroidManifest.xml!

Do it only in debug builds either via gradle's manifest placeholder or a separate AndroidManifest.xml in your debug/develop builds.

<receiver
    android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
    android:exported="true"
    android:permission="@null"
    tools:replace="android:permission">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="com.app.debug" />
    </intent-filter>
</receiver>

[reference]
https://stackoverflow.com/questions/40289999/how-to-send-fcm-firebase-cloud-messaging-push-notification-from-adb-to-device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment