I want a part(Service) in my windows phone app to run periodically.Actually its a server request , which should be made periodically and show any changes to user as notification
You should use the PeriodicTask which runs every 30 minutes in the background unless the user has not forbidden that. Notify the user about changes with a ShellToast or think about Push Notifications.
Important: Please keep in mind, that you can never rely on background tasks in Windows Phone. There are many reasons why such a task will not run. So do not outsource necessary or important work to it.
Related
I want to develop an app that has a background task that checks email servers (POP, IMAP, etc) for new email.
From what I can tell of background task, it is only allowed to run for a short time, and can be started only every 15 minutes if it is a timertrigger.
Since I want this app to run on all Windows devices, what is that proper approach to having a background task that can do this? It doesn't seem possible at this point.
But since Windows devices are able to check email in the background, there must be a way. Does anyone have any insights?
What you wish to achieve is a near real time notification of user about a mail he received . You are right that Windows doesn't allow a background task to run at intervals lesser than 15 minutes . What you are looking for is Windows Push Notification Service which can be used to send notifications from your own cloud service onto the device
It is not possible to use a background task working all time to get in real time the new emails in your case.
You must implement another approach may be using your own backend to implement push notifications to send a new notification when a new email is received.
If your provider has an API you can use it.
The company I work for is considering to build an application for Windows Phone. Well, actually we plan to build an universal app ( for phone, tablet and PC ).
There are some requirements ( especially for Phone version ), so I would like to clarify few things before allocating resources & hiring people.
I would be very grateful, if some Windows expert goes through these requirements and confirm that this is possible.
So:
1) We need to launch a call within the application.
I've found this solution:
Make a phone call in Windows Phone 8.1
The question: is it possible to launch a call without a prompt? As far as I understand this solution prompts a question to user, if he wants to call or not. Our flow and design is made in a way, that this prompt will be redundant ( of course, we launch a call on user's behalf ).
2) We need to maintain internet persistent connection and be able to react if some message comes using this persistent connection. I've checked PubNub and it seems that everything is OK and PubNub provides SDK for Windows Phone.
Important: this is not VoIP application, so it might get complicated if Microsoft has some policies that persistent connection might be used only by VoIP application ( Apple has these policies ).
Important thing: Persistent connection should stay connected, if application goes background, so there should be no "cut off".
3) We should be able to present some notification ( with sound alarm ) to user and launch the app if he "accepts" the notification. Basically, we should be able to send some message to the device using PubNub or even Microsoft WNS service for pushes and present the notification on the device. Like "Local Notification" in iOS.
Any help would be highly appreciated.
Thank you in advance.
Best Regards,
Maksim
1)Unfortunately on Windows Phone you can't start a call without the system prompt.. It's for security..
2)I can't help you here..
3)Of course you can send notification to a device. This notifications are called toast notification.
A notification's custom sound can't be setted within the app, you have to load the sound on a server or let the user decide (he can change the sound in the system settings). If you don't need a custom sound.. no problem, it'll be used the default ones and you don't have to worry about anything.
I use Parse.com to send push notifications or you can even run a sheduled task every 30 mins on the user's phone(maybe is not appropriate for your application).
In the notification you can also set the property navigationUri to open the app on a defined page.
Unfortunately you can't still customize the notification aspect(you'll be able to do it in Windows 10) and you can see the default aspect here: http://www.codeproject.com/KB/windows-phone-7/ToastNotification/PushNotification.png
In my windows phone 8 application, I would like to refresh/load some data periodically (less than 10 minutes) from server, while application running in background (ie, in dormant and tombstoned). I tried scheduled task agent and resource intensive task agent, but they are called at rate of 30 minutes gap. Please let me know is there any other solution for implementing the above said requirement.
Thanks and Regards
#nish
If you need to get data more frequently than the default available in Windows Phone, you should think about using push notifications. This won't be suitable for a full data push, but if you use it correctly, you can get a user experience that you can live with.
One common approach to this is to set up your server to send a notification to the device when there is something new to report instead of pushing a "nothing has changed" message every 10 minutes or so. If you push out a tile update notification to say, for example, "You have x unread items", the user may then click on the tile for your app and you can poll the server for new items on launch/resume. If you want a more intrusive option, you can send a toast notification as well, but in most cases the tile update will be sufficient.
This method has a few advantages.
You won't be burning through battery power polling every 10 minutes while the user is asleep
Your server will have significantly less load since it is not having to process full data requests every 10 minutes per client.
This fits in with the design philosophy of Phone apps - you are surfacing the required data to the user, while at the same time preserving battery life.
Do I understand correctly that your primary goal is to keep some host session alive by having the phone make a query periodically? If so...
I would not recommend this approach: 1) you cannot count on the phone having network connectivity when it tries to send its query. If the user puts the phone away in a pocket or purse, the odds worsen. 2) it's probably bad from a security perspective, and wasteful from a host resources perspective.
You might instead add logic to your app to resume a timed-out host session as seamlessly as possible. This would add real utility value to the mobile app value proposition over raw HTTP access to the same host.
I want a service to be active always in the background. Is this possible in the new SDK 7.1
I read through the Background File Transfers, Agents, and Alarms. I think these are only active for a period of time.
Short answer: you can't
Background agents can only run for 15 seconds every ~30 minutes. Attempting to run for longer will result in the agent being terminated and not rescheduled. Riho is referring to something different: if the user does not run the owner application for 14 days your agent won't be rescheduled (even if it's successful); the application must be run and reschedule the agent.
Your only real choice is to move the functionality to the server and use push notifications to update the phone.
Agent gets deactivated after 14 days. Within that time you must make user to open your foreground application - then you can restart the agent and 14 days counter again.
I am working on an application that is receiving XMPP notifications using the Matrix SDK. As well I am using async web service calls to receive an initial set of data from the server.
Now, I am aware that with Mango I can close the app or move it to the background and have a background task that is able to be run every 30 mins (or so) for 15sec max which obviosuly means the XMPP push isn't going to work in this scenario. Is there any way to get background apps to execute more frequently than this?
Failing that for the syncing process all I can do is every 30 mins use a web service call to get any updates and store into Isolated storage for my app to pick up when it's next run. But I believe I cannot use any UI from a background task so cannot tell the user of updates?
So, if I get an important message can I somehow override the slowness here and force my app to run and inform the user visibly that something has happened and he needs to look at it? Is this where push notifications come in?
You can use the ShellTile API to update the application's tile on the Start screen, or use the ShellToast API to show a toast to the user. Both of these can be configured to launch into a specific part of your application (deep-linking) when tapped.
If you need a constant monitoring/update/notification system for your application when it's not running, then using push notifications is probably the more appropriate approach.