I pinned a secondary tile using this code:
string secondaryTileId = "1";
var tile = new SecondaryTile(secondaryTileId, "Short name", "Display name",
"ActivationArgument", TileOptions.ShowNameOnLogo, photoUri);
var result = await tile.RequestCreateForSelectionAsync(...);
Can I update only this secondary tile via push notification (from my back-end)? If yes - where should I put this ID in this xml?:
<?xml version='1.0' encoding='utf-8'?>
<tile>
<visual lang="en-US">
<binding template="TileSquarePeekImageAndText02">
<image id="1" src="{0}"/>
<text id="1">{1}</text>
<text id="2">{2}</text>
</binding>
</visual>
</tile>
I tried to add attribute Id="1" or TileId="1" for tile node but with no luck (it updates only primary tile)
Push notifications are always sent through a channel URI and each channel URI is tied to a specific tile+user+device. So if you're sending to the channel URI for the primary tile (from PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync, in Windows.Networking.PushNotifications), that notification will always end up on that tile. There is an exception to this I'll explain in a moment.
Typically, for a secondary tile, you obtain its own channel through the [CreatePushNotificationChannelForSecondaryTileAsync][2] API instead. You'll need to send this channel's URI to your service the same way you send the one for the primary tile.
However, if you want to receive and process push notifications directly, then you can use the primary tile channel for that purpose. That is, the "ChannelForApplication" channel is used for the primary tile, toasts, and raw notifications alike, so its link to the primary tile is just part of its use. Anyway, to handle the notifications, you subscribe to the Channel object's PushNotificationReceived event, in which you can intercept the notification, check for any custom tags you want to put in there, and route it to a secondary tile if you want.
Of course, that only works for a running app. To do it when you're not running requires a background task with a PushNotificationTrigger, where you'll basically do the same time.
Related
I'm setting an activity, Receiver, as the content intent for a notification.
Intent clickIntent = new Intent(context, Receiver.class);
mBuilder.setContentIntent(PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT));
Inside Receiver Activity, I'm starting activities which are intended to be opened using TaskStackBuilder in the following way.
Intent intent = new Intent(this, Class.forName(className));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
TaskStackBuilder.create(this).addParentStack(Class.forName(className)).addNextIntent(intent).startActivities();
When the app is in the background and a notification click happens, it resumes the ParentActivity. Especially when device goes to idle and comes back. Any help? I'm cracking my head on this.
For an Android app, you should also declare android:launchMode in your androidManifest.xml file.
As discussed in the Android documentation:
An instruction on how the activity should be launched. There are four modes that work in conjunction with activity flags (FLAG_ACTIVITY_* constants) in Intent objects to determine what should happen when the activity is called upon to handle an intent.
They are:
"standard"
"singleTop"
"singleTask"
"singleInstance"
The default mode is "standard".
Solution given in this SO post - resuming an activity from a notification might also help.
I want to send a WhatsApp message to a specific contact with the Automate-app. How can do I do this?
This is the link to the app:
https://play.google.com/store/apps/details?id=com.llamalab.automate
I know this is pretty late reply.
You can make use of below blocks and build
App start block and choose activity class as
com.whatsapp.ContactPicker
Use Interact blocks for searching, selecting and messaging
Extend with Variable for searching contact and for message text
I have been trying different ways but many of them fall short of full automation.
currently, I am using blocks to send a message to (unsaved) contact. This skips the contactPicker window.
the flow blocks:
[start flow] --> [view content] --> [interact]
that's it!
in view content, you will need to specify the content uri (change number and msg):
https://api.whatsapp.com/send?phone=+966xxxxxxxxx&text=msg
in interact block, specify the (proceed) when element appeared.
the (action) is click.
and (XPATH):
fn:reverse((.//[{("android.widget.ImageButton") = null ? "true()" : "fn:choose(#class,string(#class),name())={"android.widget.ImageButton";xpathEncode}"} and {("com.whatsapp:id/send") = null ? "true()" : "#android:id={"#" ++ ("com.whatsapp:id/send");xpathEncode}"}])[1]/ancestor-or-self::)
that's it.
I'm trying to send a toast notification with a parameter to a Windows Phone 8.1 device, so when a user taps on the toast the app will show a particular page within the app, as it described in this MSDN article https://msdn.microsoft.com/library/windows/apps/jj662938(v=vs.105).aspx
This is a snippet that I use to add a parameter:
<wp:Param>?cmd=command1 </wp:Param>
this how I read it in the app:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e){
base.OnNavigatedTo(e);
string strVal1 = this.NavigationContext.QueryString["cmd"];
}
After making these changes it works correctly, but only for this first notification. In all subsequent notifications the value of the parameter read within the app is same as it was in the first notification, no matter what I've sent from the server.
Here is an example:
I'm sending a notification to device that has with this parameter in the notification payload: <wp:Param>?cmd=command1 </wp:Param> The value in this.NavigationContext.QueryString("cmd") is command1, as it should be.
Then I send a second notification with this parameter parameter
<wp:Param>?cmd=command2 </wp:Param>
the cmd's value in the this.NavigationContext.QueryString("cmd") is still returned as "command1" instead of command2 as it should be. And it works like that for all subsequent notifications until I force-restart the app.
Here is what I've tried:
Checked the Uri value in the NavigationEventArgs argument of the OnNavigatedTo event and it's same as what I see in the NavigationContext.
Double checked notification payload sent from the server (it's correct)
Checked msdn/stackoverflow/google.
Checked on both 8.1 emulator and the device (it works the same)
Questions:
Do I have to do something in the app (idk, clear NavigationContext or something), so it will be different for the next notification?
Does anyone actually has a live-app that uses partial arguments (not server-driven navigation with full url, but a partial url passed to the app + corresponding navigation from within the app) and it works for multiple subsequent notifications?
Figured out what the problem was. Two OnNavigated events are fired when app is relaunched. First one has a type of System.Windows.Navigation.NavigationMode.Reset and it has the data of the old page being reset (in my case, with the data from old notification). The second one is System.Windows.Navigation.NavigationMode.New and has the data from the new notification.
A simple check of navigation mode to make sure it's of the type .New fixed the issue:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e){
base.OnNavigatedTo(e);
if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)){
// custom navigation logic based on the data within <wp:Param/>
}
}
I try sending push notification, I'm on server-side.
Is there a way in WNS, the push service for Windows 8, to send additional parameters, that will not be displayed.
On Windows Phone 7, I use the wp:Param as Follow :
<?xml version="1.0" encoding="utf-8"?>
<wp:Notification xmlns:wp="WPNotification">
<wp:Toast>
.....
<wp:Param></wp:Param>
</wp:Toast>
</wp:Notification>
Is there an equivalent for toast for exemple ?
For toast notifications, use the launch attribute in the toast notification XML:
<toast launch="additionalContextParameters">
...
</toast>
The value specified in the launch attribute can be retrieved from the Arguments attribute passed into the OnLaunched handler (more details on MSDN).
I've successfully implemented push notifications with RavenDB (see code below). I was expecting the actual document to be included with the change notification. That way, all the UI clients can display the information. However, it seems that only the Id and Etag properties are available for the changed document.
What am I supposed to do if I want the client to be able to display information about the document? Does the client now need to make a DB call to get the document based on the ID? It seems inefficient to have to make a DB call to get the information. But, is that what is supposed to happen?
documentStore.Changes()
.ForDocumentsStartingWith("LogMessages")
.Subscribe(change =>
{
if (change.Type == DocumentChangeTypes.Put)
{
// Fire event so consumers can display document info
// Uh oh, are change.Id and change.Etag all we have here?
DatabaseItemAdded(null, new EventArgs<string>(change.Id));
}
});
Yes, you need to call the db to get the new document.
The reason for that is that it would be expensive to send the document (which may be very big) if all you need is just the notification on the change).