{"action":"opened","issue":{"url":"https://api.github.com/repos/xamarin/GooglePlayServicesComponents/issues/20","repository_url":"https://api.github.com/repos/xamarin/GooglePlayServicesComponents","labels_url":"https://api.github.com/repos/xamarin/GooglePlayServicesComponents/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/GooglePlayServicesComponents/issues/20/comments","events_url":"https://api.github.com/repos/xamarin/GooglePlayServicesComponents/issues/20/events","html_url":"https://github.com/xamarin/GooglePlayServicesComponents/issues/20","id":175103187,"number":20,"title":"Firebase Messaging not working with Xamarin.Forms","user":{"login":"softsan","id":7391319,"avatar_url":"https://avatars.githubusercontent.com/u/7391319?v=3","gravatar_id":"","url":"https://api.github.com/users/softsan","html_url":"https://github.com/softsan","followers_url":"https://api.github.com/users/softsan/followers","following_url":"https://api.github.com/users/softsan/following{/other_user}","gists_url":"https://api.github.com/users/softsan/gists{/gist_id}","starred_url":"https://api.github.com/users/softsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softsan/subscriptions","organizations_url":"https://api.github.com/users/softsan/orgs","repos_url":"https://api.github.com/users/softsan/repos","events_url":"https://api.github.com/users/softsan/events{/privacy}","received_events_url":"https://api.github.com/users/softsan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-05T16:35:22Z","updated_at":"2016-09-05T16:35:22Z","closed_at":null,"body":"### Xamarin.Android \r\nVersion 6.0\r\n\r\n### Operating System & Version :\r\nMac OSX 10.10.5\r\n\r\n### Describe your Issue:\r\ninstalled \"Xamarin Firebase - Messaging 32.4.0-beta2\" in my droid project. I get the token, but my services are never called. I want to use it for Push notification.\r\n\r\nHere is my MainActivity:\r\n\r\n       protected override void OnCreate (Bundle bundle)\r\n       {\r\n        base.OnCreate (bundle);\r\n\r\n        global::Xamarin.Forms.Forms.Init (this, bundle);\r\n\r\n        var options = new FirebaseOptions.Builder()\r\n            .SetApplicationId(ApplicationId)\r\n            .SetApiKey(ApiKey)\r\n            //.SetDatabaseUrl(\"Firebase-Database-Url\")\r\n            .SetGcmSenderId(GcmSenderId)\r\n            .Build();\r\n\r\n        var firebaseApp = FirebaseApp.InitializeApp(this, options);\r\n        // Generate token in background thread\r\n        Task.Run (() => {\r\n            var instanceID = FirebaseInstanceId.Instance;\r\n            instanceID.DeleteInstanceId ();\r\n            var iid1 = instanceID.Token;\r\n            var iid2 = instanceID.GetToken (GcmSenderId, Firebase.Messaging.FirebaseMessaging.InstanceIdScope);\r\n            Console.WriteLine( \"Iid1: {0}, iid2: {1}\", iid1, iid2);\r\n        });\r\n\r\n        LoadApplication (new App ());\r\n\r\n    }\r\n\r\nServices:\r\n\r\n\r\n\r\n    [Service]\r\n    [IntentFilter (new [] { \"com.google.firebase.INSTANCE_ID_EVENT\" })]\r\n    public class MyFirebaseIIDService : FirebaseInstanceIdService\r\n    {\r\n    const string TAG = \"MyFirebaseIIDService\";\r\n\r\n    public override void OnTokenRefresh ()\r\n    {\r\n        // Get updated InstanceID token.\r\n        var refreshedToken = FirebaseInstanceId.Instance.Token;\r\n        Android.Util.Log.Debug (TAG, \"Refreshed token: \" + refreshedToken);\r\n\r\n        // TODO: Implement this method to send any registration to your app's servers.\r\n        SendRegistrationToServer (refreshedToken);\r\n    }\r\n    // [END refresh_token]\r\n\r\n    void SendRegistrationToServer (string token)\r\n    {\r\n        // Add custom implementation, as needed.\r\n    }\r\n    }\r\n\r\n    [Service]\r\n    [IntentFilter (new [] { \"com.google.firebase.MESSAGING_EVENT\" })]\r\n    public class MyFirebaseMessagingService : FirebaseMessagingService\r\n    {\r\n    const string TAG = \"MyFirebaseMsgService\";\r\n\r\n    public override void OnMessageReceived (RemoteMessage message)\r\n    {\r\n        Android.Util.Log.Debug (TAG, \"From: \" + message.From);\r\n        Android.Util.Log.Debug (TAG, \"Notification Message Body: \" + message.GetNotification ().Body);\r\n    }\r\n\r\n    void SendNotification (string messageBody)\r\n    {\r\n        var intent = new Intent (this, typeof (MainActivity));\r\n        intent.AddFlags (ActivityFlags.ClearTop);\r\n        var pendingIntent = PendingIntent.GetActivity (this, 0 /* Request code */, intent, PendingIntentFlags.OneShot);\r\n\r\n        var defaultSoundUri = RingtoneManager.GetDefaultUri (RingtoneType.Notification);\r\n        var notificationBuilder = new NotificationCompat.Builder (this)\r\n            .SetContentTitle (\"FCM Message\")\r\n            .SetContentText (messageBody)\r\n            .SetAutoCancel (true)\r\n            .SetSound (defaultSoundUri)\r\n            .SetContentIntent (pendingIntent);\r\n\r\n        var notificationManager = NotificationManager.FromContext (this);\r\n\r\n        notificationManager.Notify (0, notificationBuilder.Build ());\r\n    }\r\n    }\r\n\r\n"}}
{"actor":{"display_login":"softsan"}}