Additional Parameters on Windows Notification Server - windows-8

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).

Related

Send WhatsApp messages automatically with Automate-App

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.

Passing partial parameter in a push notification on Windows Phone 8.1

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/>
}
}

NSAPP Custom URL Handling

I am developing an application for OSX and have to handle custom URL handling in my application
Open My profile!
While Application is Running I am able to get event inside
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent{
}
But when Application not running : it did Come to AppDidFinishedLaunching and i am not able to detect whether its invoked normally or by Custom URL ,
Is there any way to detect while App Launching ?
Thanks in advance
Instead of implementing -applicationDidFinishLaunching:, you should implement the more modern delegate method -application:didFinishLaunchingWithOptions:. You can then examine the launchOptions dictionary and look for the key UIApplicationLaunchOptionsURLKey. If you find that key in the dictionary, your app was launched in response to a custom URL. The URL itself is the value that corresponds to that key in the dictionary.
You can use the same method (looking for different keys, of course) to tell if your app was launched in response to a notifications, a location event, etc.

Update secondary tile via push notification

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.

Toast Notification not working

Below method executes on call for set Toast, but doesnot display any Toast after time elasped.
Is any more setting required for Windows 8 Metro app Toast notification
int scheduledToastCounter = 1;
public void Set_Future_Toast()
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Scheduled Toast"));
DateTimeOffset displayTime = DateTimeOffset.UtcNow.AddSeconds(3);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, displayTime);
scheduledToast.Id = "Future_" + this.scheduledToastCounter++;
ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
notifier.AddToSchedule(scheduledToast);
int scheduledToastCount = notifier.GetScheduledToastNotifications().Count;
}
}
You should set toast capable to yes in app package.
Be sure that you checked the box in the App's config file to enable Notifications.
The property settings of your object notifier told you why the toast can't be displayed:
0: Enabled, All notifications raised by this app can be displayed.
1: DisabledForApplication, The user has disabled notifications for this app.
2: DisabledForUser, The user or administrator has disabled all notifications for this user on this computer.
3: DisabledByGroupPolicy, An administrator has disabled all notifications on this computer through group policy. The group policy setting overrides the user's setting.
4: DisabledByManifest, This app has not declared itself toast capable in its package.appxmanifest file. This setting is found on the manifest's Application UI page, under the Notification section. For an app to send toast, the Toast Capable option must be set to "Yes".
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.notificationsetting.aspx
You can change directly your Package.appxmanifest from code page :
add ToastCapable to the VisualElements Tag
<VisualElements ToastCapable="true">
Some times the screen of the Package.appxmanifest dosen't have the option to change it:
Need set small icon for notifications!!!
Have you tried to make the application Toast Capable? check this thread: Toast notification isn't working?
An interesting issue I ran into is I was using toast with images. I had the images in a dependent assembly with copy to output directory. Scheduling toast just failed silently. Ondemand toast failed with an HRESULT of E_FAIL (no other information). When I finally copied the images into the main project (with copy to output directory) then they started working.