webshit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.blackforestbytes.simplecloudnotifier;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
public class FBMService extends FirebaseMessagingService
|
||||
{
|
||||
/**
|
||||
* Called if InstanceID token is updated. This may occur if the security of
|
||||
* the previous token had been compromised. Note that this is called when the InstanceID token
|
||||
* is initially generated so this is where you would retrieve the token.
|
||||
*/
|
||||
@Override
|
||||
public void onNewToken(String token)
|
||||
{
|
||||
Log.i("Firebase::NewToken", token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||
// [START_EXCLUDE]
|
||||
// There are two types of messages data messages and notification messages. Data messages are handled
|
||||
// here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
|
||||
// traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
|
||||
// is in the foreground. When the app is in the background an automatically generated notification is displayed.
|
||||
// When the user taps on the notification they are returned to the app. Messages containing both notification
|
||||
// and data payloads are treated as notification messages. The Firebase console always sends notification
|
||||
// messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
|
||||
// [END_EXCLUDE]
|
||||
|
||||
Log.i("FB::MessageReceived<0>", "");
|
||||
|
||||
|
||||
// TODO(developer): Handle FCM messages here.
|
||||
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
|
||||
Log.i("FB::MessageReceived", "From: " + remoteMessage.getFrom());
|
||||
|
||||
// Check if message contains a data payload.
|
||||
if (remoteMessage.getData().size() > 0) {
|
||||
Log.i("FB::MessageReceived", "Payload: " + remoteMessage.getData());
|
||||
}
|
||||
|
||||
// Check if message contains a notification payload.
|
||||
if (remoteMessage.getNotification() != null) {
|
||||
Log.i("FB::MessageReceived", "Notify_Title: " + remoteMessage.getNotification().getTitle());
|
||||
Log.i("FB::MessageReceived", "Notify_Body: " + remoteMessage.getNotification().getBody());
|
||||
}
|
||||
|
||||
// Also if you intend on generating your own notifications as a result of a received FCM
|
||||
// message, here is where that should be initiated. See sendNotification method below.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.blackforestbytes.simplecloudnotifier;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.google.firebase.iid.InstanceIdResult;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
|
||||
@Override
|
||||
public void onSuccess(InstanceIdResult instanceIdResult) {
|
||||
Log.d("FB::ID", instanceIdResult.getId());
|
||||
Log.d("FB::TOKEN", instanceIdResult.getToken());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user