Local notifications using ACR notifications plugin in xamarin - xamarin

I am creating a bunch of notifications using ARC notification plugin for xamarin and all of them are sent immediately after I open the app despite the fact that I am setting the date and time at least one day away from the current date. My question is, how can I set up the Notification model so that I am receiving the notification at the specified date/time?
var notif = new Notification(){
Id = count++,
Date = item.PostDate.Date,
Title = item.Type.Equals(DayType.Duminica)
? item.Title
: $"{item.Title} {Helpers.GetCurrentDateOldFormat(item.PostDate.AddDays(-13))}",
Message = item.Content,
When = App.Settings.NotificationTime // new TimeSpan(08, 00, 00)
};

Try this, It will help you.
Send a scheduled notification:
App.Settings.NotificationTime = TimeSpan.FromDays(50);
var id = await CrossNotifications.Current.Send(
item.Type.Equals(DayType.Duminica) ? item.Title : $"{item.Title} {Helpers.GetCurrentDateOldFormat(item.PostDate.AddDays(-13))}",
item.Content,
when = App.Settings.NotificationTime);
For more information click here.

Related

nativescript-phone prevents Nativescript-contacts from returning

I have an app where I want to select a person from contacts and then send a text to that person. It works as expected for the first user, but after that the app never receives control after the contact is selected. I've isolated the problem to the Nativescript-phone plugin. If you simply call phone.sms() to send a text, and then call contacts.getContact(), the problem occurs. I see this on both Android and iOS.
I've created a sample app that demos the problem at https://github.com/dlcole/contactTester. The sample app is Android only. I've spent a couple days on this and welcome any insights.
Edit 4/21/2020:
I've spent more time on this and can see what's happening. Both plugins have the same event handler and same request codes:
nativescript-phone:
var SEND_SMS = 1001;
activity.onActivityResult = function(requestCode, resultCode, data) {
nativescript-contacts:
var PICK_CONTACT = 1001;
appModule.android.on("activityResult", function(eventData) {
What happens is that after invoking phone.sms, calling contacts.getContact causes control to return to the phone plugin, and NOT the contacts plugin. I tried changing phone's request code to 1002 but had the same results.
So, the next step is to determine how to avoid the collision of the event handlers.
Instead of using activityResult event, nativescript-phone plugin overwrites the default activity result callback.
A workaround is to set the callback to it's original value after you are done with nativescript-phone.
exports.sendText = function (args) {
console.log("entering sendText");
const activity = appModule.android.foregroundActivity || appModule.android.startActivity;
const onActivityResult = activity.onActivityResult;
permissions.requestPermissions([android.Manifest.permission.CALL_PHONE],
"Permission needed to send text")
.then(() => {
console.log("permission granted");
phone.sms()
.then((result) => {
console.log(JSON.stringify(result, null, 4));
activity.onActivityResult = onActivityResult;
})
})
}

MS Teams - Don't show notification of specific message in the activity feed

Question
I have a simple Bot for MS Teams developed in C# with the Bot Builder SDK 3.15.0.0 targeting .NET framework 4.7.1.
When mentioned, it retrieves the Jira ticket Ids in the message and returns a single reply with a list of Cards, each one displaying a summary of a Jira Issue.
I'd like to know if it's possible to not populate the activity feed when sending the reply with the card attachments as it's not needed for my use case.
Example
This is how I usually build the reply to a user message
var reply = activity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.List;
reply.Attachments = thumbnailCards;
await context.PostAsync(reply);
And this is what I tried after reading the docs at https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/activity-feed#rest-api-sample
var reply = activity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.List;
reply.Attachments = thumbnailCards;
reply.ChannelData = JsonConvert.SerializeObject(new
{
notification = new
{
alert = false
}
});
await context.PostAsync(reply);
I was hoping that setting the ChannelData with notification.alert = false would just disable the notifications, but it actually doesn't display any message.
Have you tried using the Teams nuget package: https://www.nuget.org/packages/Microsoft.Bot.Connector.Teams
var reply = activity.CreateReply();
reply.ChannelData = JObject.FromObject(new TeamsChannelData()
{
Notification = new NotificationInfo(false)
});
Source for this package can be found here: https://github.com/OfficeDev/BotBuilder-MicrosoftTeams/
The alert you are getting in the activity feed is simply the "someone replied to your message" alert and is nothing special coming from the bot. This notification in the activity feed cannot be disabled as of now. Other team members won't receive this alert in activity feed unless they are following the same channel.
Sending notification using Rest API is designed to work for 1:1 chat.

Is it possible to launch native apps using Microsoft bot framework?

I am creating a Cortana skill on the Cortana canvas, I have a button.
I wanted to know if it possible to have an 'imback' type of button to open a webpage.
Ye, for example
var message = context.MakeMessage() as IMessageActivity;
message.ChannelData = JObject.FromObject(new
{
action = new { type = "LaunchUri", uri = "skype:echo123?call" }
});
await context.PostAsync(message);
this code will start a call with echo123 user on skype
Reference: https://learn.microsoft.com/en-us/cortana/tutorials/bot-skills/bot-entity-channel-data
You can supply an openUrl to a card action, or even use ChannelData to send a LaunchUri command, deep linking to an application. (I haven't tried this, but I assume 'http://websitename.com' will launch in the Cortana host platform's default browser.)
activity.ChannelData = new {
action = new { type = "LaunchUri", uri = "http://websitename.com"}
};

Schedule push notification Parse unity

Can i use Parse.com Unity plugin to schedule push notification to the user once an action is done.
i.e) Notify the user in 1 hour that his building has been built.(as in coc an example)
I don't think Push Notifications is what you are looking for here, instead I think you want Local Notifications. With Local Notifications, you schedule a notification to appear at a specified time (you usually schedule the notification when the player leaves the app, as you wouldn't normally want the notification to appear as they are playing it).
For example, you would do the following (not tested):
public void OnApplicationPause(bool isPaused)
{
// If paused, then in background
if (isPaused)
{
LocalNotification notification = new LocalNotification();
notification.alertAction = "App Name";
notification.alertBody = "The building is complete";
notification.hasAction = true;
notification.applicationIconBadgeNumber = 1; // Set's the badge count
notification.fireDate = dateBuildingWillBeFinished;
NotificationServices.ScheduleLocalNotification(notification);
}
else // Entered the app
{
// Clear notifications
NotificationServices.CancelAllLocalNotifications();
NotificationServices.ClearLocalNotifications();
}
}
Push Notifications are generally used to send messages to all players, or a group of players (such as players in the UK) to notify them of something, like a sale that is going on for in app purchases. Local Notifications are user specific, and can act more as reminders, such as your building has been completed or you haven't visited your town in a week etc.

Reminder Launch But can not open the Page in its URL

The reminder has been created with URl as below.
Problem :
To test the reminder, I have to close the app. When this reminder is launched on Home Screen which covers with a Wallpaper , the URL in the notification reminder dialogbox which ontop of the wallpaper can not be clicked or no action when press.
would appreciate help on this problem
Thanks
String strReminderNameId = System.Guid.NewGuid().ToString();
string queryString = "";
queryString = "?ReminderId=" + strReminderNameId;
Uri navigationUri = new Uri("/Testing.xaml" + queryString, UriKind.Relative);
RecurrenceInterval recurrence = RecurrenceInterval.None;
recurrence = RecurrenceInterval.Daily;
Reminder reminder = new Reminder(strReminderNameId);
reminder.Title = "Testing";
reminder.Content = "Testing 123";
reminder.BeginTime = beginTime;
reminder.ExpirationTime = expirationTime;
reminder.RecurrenceType = recurrence;
reminder.NavigationUri = navigationUri;
ScheduledActionService.Add(reminder);
It's a normal behavior. When some notification coming and screen is locked - phone is wake up and show you what's happed but you couldn't click on notification to perform provided action.

Resources