I write app on Windows Phone 8 with service of push notification (only toast), I have yet MSSQL Job which send pushes to my mobile app. Send data have this below format (typeId is int, which tell what app should do with data):
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<wp:Notification xmlns:wp=\"WPNotification\">
<wp:Toast>
<wp:Text1>title</wp:Text1>
<wp:Text2>subtitle</wp:Text2>
<wp:Data>typeId;data</wp:Data>
</wp:Toast>
</wp:Notification>
When push income when I have running app, I can service my app by method (this case works fine)
httpChannel.ShellToastNotificationReceived +=
new EventHandler<NotificationEventArgs>(httpChannel_ShellToastNotificationReceived);
httpChannel.BindToShellToast();
My problem is unable to service toast push notification, when app is not running. Push income with texts from XML, but when I click notification I go into main page of my app. How can I attach my code to decide what to do by typeId and data from XML
I find solution: XML should contains
<wp:Param></wp:Param>
section inside <wp:Toast> section. In rows I can put view adress with query string. After click notification bar I will redirect to this view. Parameters from query string will decide (in NavigateTo event) what program has to do :)
Related
For my use case, a user from C# WinForm desktop application generates some data (creates a new document in a collection named "Requests" in Firestore). What I want is that whenever a new document is created/added in the Requests collection, a notification is sent to the Flutter app. I am looking for some guidelines for a workaround regarding this using C#.
I assume that you have already connected your C# software with firebase as backend. If that is the case then:
1- First connect your flutter app to firebase.
Follow this link to do so: Connect flutter app to firebase
2- Use this link to learn and create your first cloud function on firebase.
Create first cloud function from flutter app terminal
3- Now you are in the position to create a cloud function with which a notification will be generated to the device you want on the creation of document in the request collection.
4- Deploy this function on your firebase to send notification to your required device.
exports.sendFirstNotification =
functions.firestore.document('/Requests/{documentId}')
.onCreate(async (snap, context) => {
var name = "Bilal Saeed";
var myDeviceToken = snap.data().fcmToken;
// You need this token for push notification on a device.
// Each device has its own token.
// Access it in this function.
//If you are working on C# software then create your token from flutter app
//and save it on firestore. And access that token here and save it in myDeviceToken variable.
// Currently in this function its assumed that, the newly document created //in your Request collection contains the device token which is being //assigned to myDeviceToken variable.
await admin.messaging().send({
token: myDeviceToken,
notification: {
title: `Hi, you received first notification by the help of ${name}`,
body: " Upvote his answer if he really helped you!"
},
}).then(value => {
functions.logger.log("First notification sent to the device");
}).catch((e) =>{
functions.logger.log(e.toString());
});
});
Use this command from terminal to deploy your this function.
firebase deploy --only functions:sendFirstNotification
Now create the document from your C# software and you will get the notification on your flutter app mobile device on the creation of document in Requests Collection. Congrats!
I want to make a fake incoming call in windows phone 8. As we can compose a call can i do the same with incoming call.
For Making a call i am using following code:
PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "8920383839";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();
You can't directly make a phone call (real & fake) in Windows Phone.However , if your app has ID_CAP_PHONEDIALER capability , you can show a popup for user to call the number you provided in your code.
In addition , there's no way to catch incoming calls.It's not permitted via Windows Phone API's.
You can create a fresh XAML page that strecthes to the screen and put some XAML controls inside it to get a fake incoming call screen , play a ringtone and achieve what you want.However , I doubt that application will go through Store :)
I am writing an app targeting iOS7 in Xamarin.iOS that is supposed to upload users' pictures to an online storage service as soon as he/she takes them. In order to do this, I set up an ALAssetsLibraryChangedNotification observer, like this:
NSNotificationCenter.DefaultCenter.AddObserver (ALAssetsLibrary.ChangedNotification, Callback);
and then defined a callback like this:
void Callback (NSNotification notification)
{
Console.WriteLine ("Received a notification ALAssetsLibrary : {0}", notification);
//Launch picture upload here
}
This works well, but only with the app open. Is there a way to make my app receive the notification (and process the upload) when it is backgrounded? I use iOS7 backgrounding for file transfers and long running tasks in other points of my app, but I wouldn't know how to apply this to the observer.
Extra question, I would also like to be able to filter out notifications received by this function so that I can launch my upload only if the operation is "new picture created" (currently I get notifications also when pictures are removed/edited/moved).
Thanks in advance for your replies :)
In wp7 app I simply call web browser task. But when I press back button, it closes the task but also wp7 app. So, How do I go back to app ? (with back button or something else it doesn't matter.)
WebBrowserTask task = new WebBrowserTask();
task.Uri = new Uri("myUri", UriKind.RelativeOrAbsolute);
task.Show();
If you launch a WebBrowserTask from your app, the user will return to your app by default after closing the browser with the back button.
It is possible that your code raises an exception when it is reactivated and then it crashes.
To test this, simply run it with F5 and you will see if you get an exception.
Okay, when I asked the question, I had no clue about things in Windows phone 7.
So if you navigate to a new page or start new task(like web browser), then you click the back button, it goes back to the page which called the method(navigate or new task). There's no problem with it.
However, if an exception raises when navigating back, or going back to the app from task, the program crashes with Debugger.Stop() in App.xaml.cs.
I was using PhoneApplicationService.Current.State to store datas because I was passing these datas from page to page. But this way the app stores the datas only for the thread you are using.
Well, I had the problem because when I started a web browser task , the app deleted the datas I stored with PhoneApplicationService.Current.State. When I come back from the task, I was using the this code
string str = PhoneApplicationService.Current.State["some_key"];
But datas were already deleted, so it was trying to get the values, but couldn't achieve this, so it raised an exception.
This problem doesn't appear when navigating page to page, but when starting tasks.
So my suggestion is if you want to store datas, you could use IsolatedStorageSettings.ApplicationSettings. You can find a reference here.
It 's a good approach, because not only you store the datas for the moment, you can use the datas when you open the app after closing.
in toast message in windows phone 7, when clicking on that message the
application opens thats fine,
i just want to navigate to specific page when the toast message is clicked,
is there any way to do it?
both in 7 and mango update???
or
in http://samidipbasu.com/2011/06/14/push-notification-payloads/ in this link when we read for toast notification, we have an extra parameter called wp:Param in xml format to send. How they were sending this wp:Param data in windows 7.0(before mango update). Any idea ??
Support for navigating to a particular page is supported in Mango. Below is an example that does not require an HTTP channel, but must be executed by a background agent (not the application itself):
var toast = new ShellToast
{
Title = "Title",
Content = "Toast content",
NavigationUri = new Uri("/SomeOtherView.xaml", UriKind.Relative)
};
toast.Show();
NOTE: The NavigationUri functionality is also supported by toast sent via HTTP push notifications
#curiosity .. Toast & Tile payloads are pre-defined so that the OS can process these bits coming from MPNS after your app registers shellToast/shellTile. The extra parameters in the payloads are supposed to supported starting with Mango. As your app's first page (or whichever XAML page is in the URL) launches from the deep-toast, the developer should be able to listen in on the OnNavigatedTo() event to do something special with the params in the incoming URL (query string). Please see some later posts on my blog for examples & let me know if it helps.
Thanks!
all the info you need to know about push notifications is here