Azure Notification Hub iOS template not accepting badge field anymore? - xamarin

We are registering for template push notifications using Xamarin's Azure Messaging component.
So far we've used the following template to register to notifications:
#"{""aps"": {""alert"": ""$(message)"",""badge"": ""$(badge)"",""sound"": ""$(sound)""}}"
We are passing this string to the Hub.RegisterTemplateAsync in the iOS app.
Since some time ago (less than a month), the call to RegisterTemplateAsync generates the following response:
Apr 3 13:35:03 iPhone MyApp[352] <Warning>: Error Response:<Error><Code>400</Code><Detail>The supplied notification payload is invalid.TrackingId:5dbf4199-cf52-4245-b8e4-acfa4e00cfee_G7,TimeStamp:4/3/2016 10:35:04 AM</Detail></Error>
Apr 3 13:35:03 iPhone MyApp[352] <Warning>: -------------> Notifications: RegisterTemplateAsync error: Fail to perform registration operation. Response:<Error><Code>400</Code><Detail>The supplied notification payload is invalid.TrackingId:5dbf4199-cf52-4245-b8e4-acfa4e00cfee_G7,TimeStamp:4/3/2016 10:35:04 AM</Detail></Error>
It is exactly the same binary which used to work. Now it doesn't.
When troubleshooting the issue, we found out the problem is the badge field. When we remove it, the registration to the notification hub succeeds:
#"{""aps"": {""alert"": ""$(message)"",""sound"": ""$(sound)""}}";
So now we have a broken production app in AppStore that can no longer get notifications.
Is this something that changed on the hub side or is there a chance that we did something wrong?

Have you tried using ""#(badge)"" instead of ""$(badge)""?

Related

Push Notification to specific devices on xamarin forms android/ios

I have successfully set up push notification using firebase and linked it up Azure notification hub using this guide from the Microsoft docs:
https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm
However I am now trying to push notification to specific devices using tags. There isn't currently a xamarin c# document. I have done some research around the area and found people solving what seems to be the same problem using dependency injection (which feels a little complex?). I have also found these two questions/answers:
How to push notification to specific users in Xamarin.Forms Android?
https://forums.xamarin.com/discussion/85935/how-to-push-notification-to-specific-users-in-xamarin-forms-android
Both of which point to the method "OnRegistered" which i don't seem to have? i've had another look through the documentation I followed to set up notifications in the first place and I seem to have followed it correctly?
I have the following code for android:
private void SendRegistrationToServer(string token)
{
// Register with Notification Hubs
hub = new NotificationHub(ApplicationConstants.NotificationHubName,
ApplicationConstants.ListenConnectionString, this);
var tags = new List<string>() { };
var regID = hub.Register(token, tags.ToArray()).RegistrationId;
}
I can obviously set the tags manually there, however how do i 'call' this Method again if the tags need to be changed?
So bottom line, my question is how do i set up push notification to specific devices on xamarin.forms android/ios?
Thanks.

Nativescript Android 8.0 READ_CALL_LOG Failed

Using Nativescript 5.0.
Below piece of code works well in Android ver 6.0.1
But fails to get permission in Android 8.0
Permission seeking message box does not appear.
Difference observed in both phone's permission details is, in Android 8.0, additional permission is seen as "Dial through contacts" which can not be set manually.
Permissions.requestPermission(android.Manifest.permission.READ_CALL_LOG, "Needed for connectivity status").then(() => {
console.log("refresh - Permission granted!");
this.readCallLog();
alert("in refresh Permission granted");
}).catch(() => {
console.log("Permission is not granted (sadface)");
alert("in refresh Permission NOT granted");
});
Try including READ_PHONE_STATE permission.
But to be precise nothing was changed in Android 8, but Android 9 introduced breaking changes to read call log permission which now requires phone state permission too to work.
While with earlier Android versions you could just request permission READ_CALL_LOG the newer Android versions are introducing some changes in how you could request the user call logs. The idea is to provide more information to the user explaining why you need these permissions.
An explanatory strings values should be provided in the Andorid resources
<string name="permgroupdesc_calllog">read and write phone call log</string>
<string name="permgrouprequest_calllog">Allow <b>%1$s</b> to access your phone call logs?</string>
Also, you will need to ask for a number of permissions and not just READ_CALL_LOG:
CALL_LOG
READ_CALL_LOG
WRITE_CALL_LOG
ROCESS_OUTGOING_CALLS
Details on the above here

Xamarin Forms OAuth2 Error Target of Invoke is null

After solving this problem I ran into another.
I changed the NuGet-package and implemented everything as described here.
I also added the initialization code in the AppDelegate.cs. But if I push the button to login I get the following error message: Uncaught Exception: Target of Invoke is null (NullReferenceException).
What I've done so far:
Create OAuth2Authenticator with appropriate values
Add Event handler authenticator.Completed += OnAuthCompleted;`
Initialized platform specific login UI with global::Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration.Init(); and global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);
Triggered the login with:
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);`
I'm using the Xamarin Live Player to deploy this on my iPhone.
Some ideas how to fix this?
UPDATE:
I was able to test the app with a Android emulator and there is everything working. So my assumption is that it's because of the Xamarin Live Player.

DIAL with Cobalt

Cobalt can default load the URL. We are investigating how to add the DIAL paring code to the URL. Maybe it needs a changeURL API for avoiding re-launching YouTube.
// Restrict navigation to a couple of whitelisted URLs by default.
const char kYouTubeTvLocationPolicy[] =
"h5vcc-location-src "
"https://www.youtube.com/tv "
"https://web-release-qa.youtube.com/tv "
[scenario]
launch YTTV with your remote controller
open YouTube app on your phone
try to pairing to TV
Cobalt currently doesn't implement DIAL smooth-pairing once launched, but it does support being launched with alternate query parameters via the --url= command-line parameter.
For example:
https://www.youtube.com/tv?...anything...
Will pass the navigation whitelist.
Full implementation of smooth-pairing support is planned for Q1 2017.

Parse related remote calls failing in app

I have developed an Ionic Framework App using Parse which works great on my desktop browsers. No errors or warnings in the browser console.
But when I package the app and test in on my actual Android 4.4.4 device, the Parse related functionalities does not work. When I tried to debug the App by installing the .apk using GapDebug tool, I see the below in the console.
POST https://api.parse.com/1/login net::ERR_CACHE_MISS
POST https://api.parse.com/1/requestPasswordReset net::ERR_CACHE_MISS
Below is the complete console log details for the Parse Login activity.
POST https://api.parse.com/1/login net::ERR_CACHE_MISS parse-1.3.3.min.js:1
b._ajax parse-1.3.3.min.js:1
b._request parse-1.3.3.min.js:1
b.User.b.Object.extend.logIn parse-1.3.3.min.js:3
b.User.b.Object.extend.logIn parse-1.3.3.min.js:3
$scope.validateUser login.controller.js:22
$parseFunctionCall ionic.bundle.js:20124
(anonymous function) ionic.bundle.js:50863
Scope.$eval ionic.bundle.js:22178
Scope.$apply ionic.bundle.js:22276
(anonymous function) ionic.bundle.js:50862
jQuery.event.dispatch jquery.js:4409
elemData.handle jquery.js:4095
triggerMouseEvent ionic.bundle.js:2811
tapClick ionic.bundle.js:2800
tapTouchEnd ionic.bundle.js:2918
POST https://api.parse.com/1/requestPasswordReset net::ERR_CACHE_MISS
For getting all the data for a particular class, I get the below failure object.
Failed to load resource: net::ERR_CACHE_MISS https://api.parse.com/1/Items
XMLHttpRequest failed: {"statusText":"","status":0,"response":"","responseType":"","responseXML":null,"responseText":"","upload":{"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null},"withCredentials":false,"readyState":4,"timeout":0,"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null}
The issue was with permission. It was failing because the app was not able to connect to internet.
Somehow the Network Access permission entry got deleted in the manifest file. After adding it to manifest, it worked.

Resources