1

I've followed 2 tutorials on this - Android Push Notifications in Xamarin.Forms, setup AppCenter.ms and Firebase, following all instructions:

https://www.youtube.com/watch?v=t-mvM6visKU

https://www.youtube.com/watch?v=TT11e_YCRwI

Everything works (except notifications), AppCenter.ms even says 2/2 messages sent. When I run the app first on a physical device from Visual Studio it says 1/1 sent. Then I try on an Emulator (Pixel 2, Oreo 8.0) it says 2/2 sent, so they are being registered.

But notifications never come through on either device. I followed these tutorials exactly including adding the

<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>

How can I debug this - any ideas?

niico
  • 11,206
  • 23
  • 78
  • 161
  • 1
    Hi ,if show 1/1 sent , it means the message has been sent and device has been received .Pull down the notification bar of Android phone to see if the notification exists. Perhaps the notification does not appear in the form of a pop-up window. – Junior Jiang Nov 29 '19 at 05:44
  • I have pulled notification bar down - definitely nothing there on device or emulator. No app badge. Notifications definitely enabled for all apps. Nothing comes in. – niico Nov 29 '19 at 09:33
  • Okey , do you have a try with firebase to see whether device can receive notification . – Junior Jiang Dec 02 '19 at 01:55
  • I've tried but it's asking for lots of things I don't understand, FCM Registration tokens, Andriod Notification Channel. I've looked these up but it's so far out of what I've looked into for Xamarin Forms. Any idea what I need to enter for the above fields and how I find that info? Thanks. – niico Dec 02 '19 at 10:26

2 Answers2

1

I suggest you follow the official documentation. We have pretty good guides. As for the lines you added in the manifest, they should be deleted. If that still doesn't help, send me the verbose logs, I will take a look.

annaoomph
  • 552
  • 1
  • 4
  • 22
  • Thanks. It's marked as 'Preview' - would you say it's ready to be used in production? (not asking for a legal declaration - just in your opinion would you say it's probably fine?) – niico Dec 05 '19 at 12:31
  • @niico what exactly are you referring to? I mean "Preview" – annaoomph Dec 05 '19 at 15:03
  • Login to AppCenter, click 'Push' in the nav, it says 'Push Notifications (Preview)' - implying the service might be buggy and isn't ready for production? – niico Dec 06 '19 at 07:33
  • I've followed the documentation you linked to, it's basically all stuff I've done before. I started from scratch, didn't do the manifest stuff this time. 0/0 Sent. – niico Dec 06 '19 at 11:36
  • I've run the app both on a physical device and emulator from VS. – niico Dec 06 '19 at 11:49
  • @niico did you configure the app in AC before or after starting the app? Is there pushToken in the VERBOSE logs? Also, make sure you followed the 1st link I sent (which contains info for Xamarin.Forms). Preview label should be fine. – annaoomph Dec 06 '19 at 12:25
  • I started the app before and after configuraint in AC. I did follow the first link. The lines weren't in the manifest (last time I had to add them manually, but only did so after it didn't work). Are you referring to Visual Studio Verbose logs? Please explain more, what logging? – niico Dec 06 '19 at 13:09
  • I've appended /log to the end of the VS shortcut, enabled diagnostic logging but the ActivityLog.xsl doesn't contain any new information when I run the app. – niico Dec 06 '19 at 13:48
  • @niico the order should always be 1. Configure Push on portal 2. Build and start the app for the first time (otherwise it won't work). You can enable verbose logging using AppCenter.LogLevel = LogLevel.Verbose; before App Center start and then looking under VS Output window. – annaoomph Dec 06 '19 at 14:33
  • What?! So if I just build an app ever, then add it to the portal, then build again it'll never work? What if I need to add Push to an existing app, you're saying I have to start a new solution and rebuild the whole thing?! This doesn't sound right and I misunderstanding? – niico Dec 06 '19 at 15:04
  • That's not a problem if you want to add Push to an existing app. Let's say you have an app without Push, and at some point you decide to add it. Then, the order is -> you configure Push in the app on portal -> add Push to the app (in Start method at least) -> start the app. Not the other way around. If, for example, you have an app which already starts the Push service for some reason, but backend isn't yet configured (which is a very unlikely use case), then you'll just have to -> configure the portal Push -> delete the app from device and re install it again. Hope that makes sense to you. – annaoomph Dec 06 '19 at 15:33
  • @niico oh! I think you misunderstood me. By "configure the app" I meant "configure Push service in the existing app on the portal". – annaoomph Dec 06 '19 at 15:54
  • OK I deleted the app from the phone, then tried to run it again - that seems to have registered it now thanks, AppCenter sent a push that was received on the Android handset (saying 2/2, not sure what the other 1 is). I immediately tried again and nothing was received though after 10 minutes and it says sent again. I tried 3 more times, no notifications came through but all say 2/2 sent. This looks VERY unreliable from where I'm sitting, or am I doing something wrong? – niico Dec 06 '19 at 16:57
  • I did the same on iOS still says 0/0 sent. – niico Dec 06 '19 at 17:14
  • I deleted the app on Android, ran the debugger again and it put it back on the phone. Now AC no longer sends notifications to the phone again - saying 1/1. No idea what the other 1 is, the emulator I use also doesn't receive notifications. – niico Dec 06 '19 at 17:45
  • Are you sending push in background or foreground? Do you have PushListener set? The other 1 might be just another registration. – annaoomph Dec 06 '19 at 18:56
  • I'm sending through the web interface. No listener set. – niico Dec 08 '19 at 11:33
  • You should set a listener for your notification, as here : https://learn.microsoft.com/en-us/appcenter/sdk/push/xamarin-forms#intercept-push-notifications – annaoomph Dec 09 '19 at 11:02
  • Thanks - the link to docs above and the video tutorial didn't mention this. Wouldn't a listener require the app to be running to work? I need push notifications to always come through regardless of whether the app is running. I don't need to intercept them in the app. – niico Dec 09 '19 at 12:42
  • This listener is called directly when the notification is received in foreground or through tapping on notification if it's in background. – annaoomph Dec 09 '19 at 13:11
  • OK, but the notification should come through first no - regardless of whether a listener is present? – niico Dec 09 '19 at 13:50
  • How can a user tap on a notification that was never received? – niico Dec 09 '19 at 15:04
  • Yes, if you're in the background. In the foreground you'll need the listener. – annaoomph Dec 09 '19 at 15:57
  • The app wasn't running at all, and the notifications don't come through – niico Dec 09 '19 at 16:32
  • 1
    That's not how it should be, can you click a blue bubble at the right bottom of the website and open a support ticket, and attach the VERBOSE logs from your app? – annaoomph Dec 10 '19 at 11:36
0

When setting up Firebase I chose not to enable Google Analytics. This seems to just break notifications.

When I enabled Analytics notifications started working. But actually not reliably.

niico
  • 11,206
  • 23
  • 78
  • 161
  • I tried both enabling and disabling Analytics. App still not receiving notifications. I also tried to create new xamarin project, new project in firebase and new app in app center. – Roshni Gandhi Jan 30 '20 at 12:10