Dissable auto push remote notification ios - c#

I am overriding both DidReceiveRemoteNotification and ReceivedRemoteNotification and leaving them empty in an attempt to prevent my remote notifications to push automatically, but it does not seem to help. Because every time I send a postman request for the notification, they still show up.. How can i prevent the notification from pushing until the app has met the necessary requirements (user is signed inn) ?

When your app starts up, register or unregister, as soon as you know the app state
Unregister:
UIApplication.SharedApplication.UnregisterForRemoteNotifications();
Register:
UIApplication.SharedApplication.RegisterForRemoteNotifications();

Related

What and where is the DefaultFullSharedAccessSignature in my Azure Notification Hub

I am following the tutorial on here by microsoft on setting up a notification hub for an iOS app. The "Test Send" section of Notification Hub succeeds in sending the notification, and I actually receive it on my registered device.
However, when I invoke an notification from my C# backend, nothing happens. I even get HttpStatusCode.OK after invoking SendAppleNativeNotificationAsync.
So the Azure Hub setup in Azure portal seems to be fine since the test send works, but my backend is probably wrong somewhere.
On the code below:
private Notifications() {
Hub = NotificationHubClient.CreateClientFromConnectionString(
"<your hub's DefaultFullSharedAccessSignature>",
"<hub name>");
}
What exactly is DefaultFullSharedAccessSignature, and which part of my connection string do I get that?
At the moment here is what I have:
Hub = NotificationHubClient.CreateClientFromConnectionString(
"Endpoint=sb://myappnotificationsns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=somerandomcharacterhere27374+7384bvbher38434fve0=",
"myappnotifications"
);
nb: thats a fake connection string.
Is this correct or wrong?
Okay, so turns out the above setup is correct.
My issue instead was that the username passed during token registration was null. There is no exception or error from the SDK for some reason. Had to hunt furiously to find the issue.
Hope this helps someone someday.

Azure Notification Hubs Register Device Error 404

This is the first time I'm using Azure Notification Hubs and I'm having some trouble getting it working properly with my application.
The part I'm stuck on (at the moment) is registering my device with the notification hub. I'm using the backend method to do the registration ... that is, I'm creating an Installation object and using the CreateOrUpdateInstallationAsync method to register the device via my Web API. I'm only testing it at this stage so I'm hitting my API endpoint with dummy data via Postman.
When I step through my code, I'm getting the following error when I execute CreateOrUpdateInstallationAsync ...
The remote server returned an error: (404) Not Found. Entity does not
exist.TrackingId:203cba37-007d-4dcb-ae25-ced33fa012aa_G1,TimeStamp:2/4/2018
10:24:02 PM
I've tested that I am connecting to the Notification Hub correctly by calling GetAllRegistrationsAsync. This returns an empty list (expected) and no error ... so I have my endpoints set up correctly. I'm wondering if there is a problem with my dummy data? For the installation Id, I've just created a random GUID (Guid.NewGuid). The Device ID and Push Notification Handle are random numbers and letters. And I'm testing this for the Android platform (NotificationPlatform.Gcm).
Has anyone seen this error before and know what it means? Am I able to just use random data for testing purposes (I'm only interested in registering devices at this stage) or do I need legitimate data (real device id's, etc)?
Thanks in advance.
The CreateOrUpdateInstallationAsync method would essentially invoke the REST API Create or Overwrite an Installation. When you register with a notification hub from your custom backend using the Installation, the core code would look like as follows:
NotificationHubClient hubclient = NotificationHubClient.CreateClientFromConnectionString(listenConnString, hubName);
await hubclient.CreateOrUpdateInstallationAsync(installation);
Note: You could install the Microsoft.Azure.NotificationHubs package for back end operations.
For a simpler way, I just created a console application and test this operation as follows:
Note: I just created a new Azure Notification Hub and did not set any notification settings. And I set a GUID as the InstallationId and a random string as the PushChannel, the rest operation could work as expected.
And I could retrieve the previous added registration as follows:
Has anyone seen this error before and know what it means? Am I able to just use random data for testing purposes (I'm only interested in registering devices at this stage) or do I need legitimate data (real device id's, etc)?
The operation could work on my side, I would recommend you debug your application and leverage fiddler to capture the network traces to narrow this issue. Moreover, you could follow Registration management for more details about registering devices with azure notification hubs.
Ok, it turns out that I had the wrong value for Hub Name when instantiating the NotificationHub object using NotificationHubClient.CreateClientFromConnectionString. I was using the namespace, instead of the hub name (visible on the Overview tab in the Azure Portal).

Context.Wait() isn't triggered by an attachment

[Update] I verify another thing and it appears that my bot, hosted in Azure, just doesn't accept anymore any kind of attachment...
I just update to the 3.81 version of the Bot Framework and one thing isn't working anymore.
I expect from the user to send either a text or an attachment. So I wait for the response with context.Wait(waitForAnswer)
But the method waitForAnswer doesn't trigger if the user sends an attachment... Now if I want to receive one, it seems that the only way is using PromptDialog.Attachment... but this isn't fine for my use case because I don't know if the user will send an attachment or a simple text message.
Note that within the emulator, the function waitForAnswer is correctly triggered by an attachment... But when I try to use Telegram channel or simply the webchat, problem rise

Notification on sent out email using EWS

I have done streaming notification on new arrival email but when ever user send any email to anyone, Can it generate any event though streaming, pull, push notification. I am trying to track each and every email body that is being sent out from account.
There is no Send notification that gets fired however when a user sends an email the default behaviour is to save a copy in the SentItems folder so if you subscribe to the CreateItem event on the SentItems folder that should probably cover what your trying to do (you can test that without writing any code using the EWSEditor).
You can configure the Email Client to not save a copy in the SentItems folder and if the user is trying to hide something they may delete it before you can get at it. Transport Agents or Jornaling should be used when you need to do this kind of thing for auditing/compliance reasons because it ensure you always capture the message.

How to update MPNS channel URI after app inactivity

A stored notification channel URI may go stale while my app is inactive -- i.e., stopped, tombstoned or dormant. What is the best practice for updating the channel URI with my web service after a period of inactivity?
Various articles on the web mention "retrieving" the URI in order to send it to the web service. But as far as I can tell, the only way for my app to learn the channel URI is via the ChannelUriUpdated event on HttpNotificationChannel, and raising that event is not under my control. MPNS may have changed the URI while my app was inactive. If the app could not respond to ChannelUriUpdated, the URI would then be stale in both my app and my web service.
Perhaps a channel returned by HttpNotificationChannel.Find is guaranteed to always have an up-to-date channel URI?
General best practice is to request the current channel Uri whenever the app is started. Within the app you should keep track of the last value returned (across application invocations) and if it's changed to upload to your web service.
Please follow this Updated document here. what it does is, it executes a script on insert of the channel uri, it checks if the channel URI exits, if it exists it does not insert the record, else it inserts the record. so, once the channel uri for a device expires, a new channel uri is given to the device in that case, the comparision mismatches and the new channel uri is inserted. by doing that the device is always sent the notification.
Note:- to leverage that functionality, you have to send for insert every time your app starts. hope this helps.

Categories