Hi, I am trying to implement Push notifications in my Xamarin project using the .NET SDK,
Backendless Version ( 5.x, Online )
Client SDK .NET
Application ID: 79BDE2FC-14C7-12E4-FFFB-7C0B32BC4600
Expected Behavior
I am using the PushNotification Plugin for Xamarin to use Firebase to receive the token.
In the device registration :
CrossPushNotification.Current.OnTokenRefresh += (s, p) =>
{
System.Diagnostics.Debug.WriteLine($“TOKEN REC: {p.Token}”);
Backendless.Messaging.RegisterDevice(CrossPushNotification.Current.Token);
};
using the token received I understand that the device should be registered and seen in the Deviceregistration table.
Actual Behavior
gives me an error:
System.NullReferenceException: ‘Object reference not set to an instance of an object.’
I have also tried with the RegisterDeviceAsync method but the same thing happens.
Please if anyone has tried Push Notifications in Xamarin please help me.
Thank you
Maria
Hello @Maria_Regil ,
thanks for reporting this issue.
Our engineer already looking into it.
Regards,
Stanislaw
Thanks Stanislaw,
It’s my fault, I had not initialized the API correctly, now I have registered the device, but when I add in AndroidManifest.xml the service:
when I start the app I get a java error:
Java.Lang.RuntimeException
Mensaje = Unable to instantiate service com.backendless.push.BackendlessFCMService: java.lang.ClassNotFoundException: Didn’t find class “com.backendless.push.BackendlessFCMService” on path: DexPathList[[zip file “/data/app/com.bizintek.resboardcontrol-fROWTwHy7n8NoYpeu3Ibpw==/base.apk”],nativeLibraryDirectories=[/data/app/com.bizintek.resboardcontrol-fROWTwHy7n8NoYpeu3Ibpw==/lib/arm64, /data/app/com.bizintek.resboardcontrol-fROWTwHy7n8NoYpeu3Ibpw==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]
could it be some missing configuration?
thanks
Maria
Hello, @Maria_Regil .
Could you please provide your code (push notification service)?
Regards, Nikita.
Hi @Nikita_Fedorishchev
this is from de documentation.
thanks
@Maria_Regil
This code must be wrapped in the application tag, also replace “service” with “receiver” like this: <application android: label = "PushNotify.Android" android: theme = "@ style / MainTheme">
<receiver android: name = "com.backendless.push.BackendlessFCMService">
<intent-filter>
<action android: name = "com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</receiver>
</ application>
Regards, Nikita.
1 Like
@Maria_Regil, let me know if this helped you.
It’s ok now, thanks you ! ![:blush: :blush:](https://support.backendless.com/images/emoji/twitter/blush.png?v=9)
1 Like
Hi @Nikita_Fedorishchev ,
Doing some tests with the Push notification I have seen that the device disappears from the DeviceRegistration table, is it normal? Shouldn’t it remain in the table?
thanks
Maria
Hello, @Maria_Regil .
Send the “expiration” DateTime?
parameter to the method. To have your device removed on the designated date.
Regards, Nikita.
thanks @Nikita_Fedorishchev, i will try it.
What if you never want it to be removed?
@Maria_Regil, if the value is null, then the device will not be removed, but, apparently, it is not working correctly now. I will consider this problem in more detail.
@Maria_Regil, tell me, when did you register this device and how long did it take until it was deleted?
@Nikita_Fedorishchev , I think a few minutes. I was sending test notifications and suddenly there was no more device.
Ok, thanks, I will investigate this issue.
Regards, Nikita.
@Maria_Regil, have you registered the same device multiple times as far as I understand? In the end, when you sent the push, the same device was registered for different token values. Accordingly, the old value was removed from the database.
Regards, Nikita.
@Nikita_Fedorishchev
ok, but if I register the same device twice, one of the registrations should be deleted, not both, right?
The device registration should be done when the token received from Firebase changes, is that right?
If so, the record in the table should be modified with the new token, or delete the old record and add the new one.
Please tell me how backendless handles firebase token and device issues.
Thanks
Maria
@Maria_Regil, have all entries been deleted?
I checked it several times, it was not possible to reproduce such a scenario.
All records of the same device were deleted except for the last one.
@Maria_Regil, please describe the detailed steps so that I can reproduce your problem.
Regards, Nikita.