Last active
March 2, 2023 02:35
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
!!! Required adb PATH on env var !!! | |
[Usage] | |
Run with python: | |
$ python3 send_push_or_deeplink.py | |
or add exec permission | |
$ chmod +x send_push_or_deeplink.py | |
and run ever | |
$ ./send_push_or_deeplink.py | |
''' | |
import os | |
params=[] | |
commands='' | |
app=input("Input app package-name (e.g com.myapp.name)> ") | |
select=input('\n[1] Push Notification -- [2] Deeplink\n') | |
if select == "1": | |
while True: | |
data=input("Add data (key, value) or [enter] to run:\n") | |
if len(data) == 0: | |
break | |
data=data.split(",") | |
params.append("\"{}\" \"{}\"".format(data[0], data[1])) | |
commands='adb shell am broadcast -n {}/com.google.firebase.iid.FirebaseInstanceIdReceiver'.format(app) | |
commands+=' -c {} -a com.google.android.c2dm.intent.RECEIVE '.format(app) | |
for param in params: commands+=' --es {}'.format(param) | |
elif select == "2": | |
deeplink=input('Input deeplink::> ').replace("&","\&") | |
commands=('adb shell am start -a android.intent.action.VIEW -d "{}" {}'.format(deeplink, app)) | |
else: | |
print('Invalid option. Bye! 😥') | |
exit() | |
os.system(commands) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No root required 😎
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.[reference]
https://stackoverflow.com/questions/40289999/how-to-send-fcm-firebase-cloud-messaging-push-notification-from-adb-to-device