How can I update my tiles in the background while my app is not running in the foreground? I tried looking into push notifications, but I don't think that'll get me anywhere.
Where to begin? I know how to create tiles already.
An app cannot update it's tile without running at least once. Because apps do not run immediately on installation, it isn't possible for a tile to be "live" until it is launched. After app installation, the user needs to launch the app for it to set up and begin receiving updates in any form (whether they are push notifications, periodic updates, scheduled notifications, or local notifications raised with or without a background task). The default tile will be shown from the point the user installs the app until the time the app sets up tile updates.
MSDN has a good article on choosing the right notification delivery mechanism, which also links to related code samples:
http://msdn.microsoft.com/en-us/library/windows/apps/hh779721.aspx
As far as I know, you have to use a background task. If the user hasn't run the app once, you can't show any interactive tile data.
You have to use a TileNotification from the Windows.UI.Notifications namespace. The documentation for the namespace is here.
There's also an example Stocks app that uses notifications here (search for 'Tiles and notifications')
Further, there's an 'App tiles and badges' sample that shows both text and image updates to a live tile.
Adding Live tiles to the desktop using c# code:
List<Uri> StoryUrls = new List<Uri>();
StoryUrls .Add(new Uri("tiles.xml"));
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdateBatch(StoryUrls, PeriodicUpdateRecurrence.HalfHour);
The xml should be in the following format:
tiles.xml should follow microsoft format show in step 5 Here
Hope this helps
Related
In our app users can track and submit journeys they have recorded. I need a simple way of creating a task in iOS. I have already created and tested this on Android. It works via:
The user selects the journeys they would like to submit.
Taps sync and a foreground service is created that syncs the journeys to our API.
This service will continue to sync journeys even if the app is put into the background or even closed.
So in short how can i achieve this on iOS 9-13?
I have already tried creating a background-safe tasks using:
nint taskID = UIApplication.SharedApplication.BeginBackgroundTask( () => {});
However, this only gives the task 2 mins to run which isn't enough. I have looked into the NSURlSessions but they require URls, whereas we are using our own API wrapper.
I would simply like a way of creating a task when the user taps 'sync' and this task also being capable to run in the background. I am not too bothered if the task is cancelled when the app is closed, although if possible would like the task to continue.
Thanks.
This service will continue to sync journeys even if the app is put
into the background or even closed.
First, if your app is closed in iOS, I'm sure do can't run any service in background.
Then if your app is put into background, Apple has strict limit to allow apps running in the background. background-tasks has time limits, you can read the document about more information. There is a section about handling-background-task-time-limits which you can have a try.
Also, Apple allows some specific apps to run in background which have to perform tasks in the background. For example, app that needs to play music in background, update location in background and etc. You can see the Application Registration Categories here. If your app meets the requirement there, you can apply for a background running permission from system.
Refer: Backgrounding in Xamarin.iOS
I would advise you to leverage on Shiny to achieve it.
PerformFetch is the closest thing to what you ask for, it will run in the background and update your app when iOS thinks it is needed (it predicts that according to the previous behavior the user will soon open your app and that the new content is available).
The only alternative is to send the push notification when you want the app to be updated.
That's about it, I understand your wish but it is just that - a wish and not something that can be real.
I have UWP application and I want to retrieve the Power and Sleep setting information and display it to the UI.
For example:
On Windows settings, I set the Sleep timer to Never
Then when I open my UWP application and go to Power setting UI,
it will reflect the selected settings in the dropdown list.
My question now is, Is it possible to control (Read, Update) the Power and Sleep setting in Windows 10 thru C# programming. If yes, Any Tips on how to Achieve this feature in my App that I can Change and Display the Sleep settings to the application UI.
Any suggestion or comments are appreciated.
I can not find any api to change it but you can send the user to setting page to set the power.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:powersleep"));
If you want your app run without off screen like a video app that you can use this code.
var displayRequest = new DisplayRequest();
displayRequest.RequestRelease();
See: Launch the Windows Settings app - UWP app developer
I have an app that needs to create a pop up to notify the user of something, even when the app is closed. I would like it to be fullscreen, but if that's not possible, a pop up that takes up most of the screen will do. I don't know how to make part of the app run in the background on Android and iOS to check if it's time for the pop up. I also don't know how to go about making the actual pop up. Any help would be greatly appreciated!
Side notes: I am using a cross platform Xamarin.Forms app. I have a main page that the user can set the time they want the pop up to appear, and I save this to the Application.Current.Properties dictionary for data persistence.
Background tasks on mobile has quite a lot of limitations. Which is logical. The user would not like if some app will always run in background and collect user data, drain the battery or affect overal performance of the the mobile device. Therefore for there are strict set of rules every developer must follow when creating a background tasks.
You best bet would be to use local notifications, there is a well documented open source library that you can use for this. There will be no pop-ups but notifications which you could customize according to OS guides.
In my Windows phone app, I store all the contacts in a separate list rather than fetching using Contacts.SearchAsync method whenever I need details about a particular contact.
Now I need to get a notification whenever the user updates, adds or deletes any of the contacts, so that I can keep keep my list updated. How would I do this in Windows phone?
I don't know if you can add such an event in WP - I doubt it, if I'm wrong please correct me.
One solution which you may try is to add a background agent which will periodically chcek for changes. But it seems to be a walk around the problem.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202942(v=vs.105).aspx
I will also recall what #Toni Petrina ansered to this question:
"All connections of any kind are suspended when the application is in background mode. Your application cannot really respond to any events at all.
Unfortunately, this is the limitation of the sandboxed app model which lives in isolation from the operating system. When in background, it is suspended and no sensors nor connections live."
So when you leave your App it can't get notification from operating system. Some job can be done only by backgroud agents described at link above.
Maybe upcoming WP 8.1 will change something in this matter.
Short answer: There is no such notification or event available, you should just check the current list of contacts for changes whenever your app starts.
I am trying to create an specific Calendar for Windows8 Metro User Interface.
All I want to do for now is to update my tile at 12:00 am (showing the current date on the tile) even while the program is not running.
WinRT provides multiple solutions for such task but I can not use any of them for various reasons:
It is possible to Register a Maintenance Background Task but they only run if the device is on AC power.
It is possible to Register a Periodic Cloud URI but they only run if the computer is connected to the internet.
It is possible to Register a Background Task on Timer but they only run if the user add them to lock screen.
It is possible to Register a ScheduledTileNotification but it's single, non-recurring scheduled update to a tile.
is there any other solution?
I think the answer here is that you have to get added to the lock screen -- this isn't something that requires the user to dig into PC Settings. You can prompt to be added to the lock screen using the supported api. Sample code is included in the Documentation -- it's a simple call, and a case of handling the result.
You don't need to be on the lock screen. Look into using scheduled tile notifications:
A code sample is here:
http://code.msdn.microsoft.com/windowsapps/Scheduled-notifications-da477093