Skip to content

Commit

Permalink
Add push delegate template
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed May 7, 2024
1 parent 0953bd9 commit ebb525e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ItemTemplates/GpsDelegate/GpsDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public partial class MyGpsDelegate : GpsDelegate
{
public MyGpsDelegate(ILogger<MyGpsDelegate> logger) : base(logger)
{
// settings as you need
// this.MinimumDistance = Distance.FromMeters(200);
// this.MinimumTime = TimeSpan.FromSeconds(15);
}

public override async Task OnGpsReading(GpsReading reading)
Expand Down
20 changes: 20 additions & 0 deletions ItemTemplates/PushDelegate/.template.config/ide.host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "http://json.schemastore.org/ide.host",
"icon": "shiny.png",
"appliesTo": "UseMaui",
"defaultItemExtension": "cs",
"itemHierarchyPaths": [ ".NET MAUI" ],
"unsupportedHosts": [
{
"id": "vs",
"version": "(,17.3)"
}
],
"requiredComponents": [
{
"id": "Microsoft.VisualStudio.ComponentGroup.Maui.All",
"hostId": "vs",
"componentType": "SetupComponent"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions ItemTemplates/PushDelegate/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Shiny",
"classifications": [ "MAUI", "Code" ],
"identity": "Shiny.Templates.PushDelegate",
"groupIdentity": "Shiny.Templates",
"name": "Shiny Push Delegate",
"shortName": "shinypushdelegate",
"tags": {
"language": "C#",
"type": "item"
},
"primaryOutputs": [
{
"path": "GpsDelegate.cs"
}
],
"postActions": [
{
"id": "openInEditor",
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"description": "Opens GpsDelegate.cs in the editor.",
"manualInstructions": [],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "0"
},
"continueOnError": true
}
],
"sourceName": "PushDelegate",
"defaultName": "PushDelegate",
"symbols": {
"namespace": {
"type": "parameter",
"datatype": "text",
"description": "Namespace for this class",
"replaces": "ShinyApp"
}
}
}
36 changes: 36 additions & 0 deletions ItemTemplates/PushDelegate/PushDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Shiny.Push;
#if APPLE
using UIKit;
using UserNotifications;
#endif

namespace ShinyApp;


public partial class MyPushDelegate : PushDelegate
{
public override async Task OnEntry(PushNotification notification)
{
}

public override async Task OnReceived(PushNotification notification)
{
}

public override async Task OnNewToken(string token)
{
}

public override async Task OnUnRegistered(string token)
{
}
}

#if APPLE
public partial class MyPushDelegate : IApplePushDelegate
{
public UNNotificationPresentationOptions? GetPresentationOptions(PushNotification notification) => null;

public UIBackgroundFetchResult? GetFetchResult(PushNotification notification) => null;
}
#endif

0 comments on commit ebb525e

Please sign in to comment.