Skip to content

How to send push notification from app to app or app to all apps...

Notifications You must be signed in to change notification settings

ANASDAVOODTK/Android-Push-Notification

Repository files navigation

Android-Push-Notification

How to send push notification from app to app or app to all apps...

1) Add this dependencies to build gradle (App) cate

  implementation 'com.android.volley:volley:1.1.1'

2) Add this menifest setting

 i) <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

ii) <service
        android:name=".FirebaseMessagingService"
        android:permission="TODO"
        tools:ignore="ExportedService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

3) Then add this two calss in to your packages 'FirebaseMessagingService & FcmNotificationsSender'

4) Then change your Mainactivity like above Thats all.

// for sending notification to all

    FirebaseMessaging.getInstance().subscribeToTopic("all");

// fcm settings for perticular user

    FirebaseInstanceId.getInstance().getInstanceId()
            .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
                @Override
                public void onComplete(@NonNull Task<InstanceIdResult> task) {
                    if (task.isSuccessful()) {
                      String  token = Objects.requireNonNull(task.getResult()).getToken();

                    }

                }
            });

About

How to send push notification from app to app or app to all apps...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages