Skip to content

Commit fcc90cd

Browse files
Test
1 parent edc8143 commit fcc90cd

File tree

7 files changed

+56
-58
lines changed

7 files changed

+56
-58
lines changed

Notifo.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31019.35
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32929.385
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.iOS", "sample\Sample.iOS\Sample.iOS.csproj", "{2536F86F-CA74-469A-AFAC-A8BE7B71CED3}"
77
EndProject

sample/Sample.Android/Resources/Resource.designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/Sample.iOS/Sample.iOS.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<AssemblyName>Sample.iOS</AssemblyName>
1515
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
1616
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
17-
<ProvisioningType>manual</ProvisioningType>
17+
<ProvisioningType>automatic</ProvisioningType>
1818
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1919
</PropertyGroup>
2020
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
@@ -47,13 +47,12 @@
4747
<ErrorReport>prompt</ErrorReport>
4848
<WarningLevel>4</WarningLevel>
4949
<MtouchArch>ARM64</MtouchArch>
50-
<CodesignKey>iPhone Developer</CodesignKey>
50+
<CodesignKey>Apple Development: Sebastian Stehle (QXSQNQVQ76)</CodesignKey>
5151
<MtouchDebug>true</MtouchDebug>
5252
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
5353
<MtouchLink>None</MtouchLink>
5454
<MtouchInterpreter>-all</MtouchInterpreter>
55-
<CodesignProvision>
56-
</CodesignProvision>
55+
<CodesignProvision>VS: io.notifo.xamarin.sample Development</CodesignProvision>
5756
</PropertyGroup>
5857
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
5958
<DebugType>none</DebugType>
@@ -178,9 +177,9 @@
178177
<Name>Sample</Name>
179178
</ProjectReference>
180179
<ProjectReference Include="..\SampleNotificationServiceExtension\SampleNotificationServiceExtension.csproj">
181-
<IsAppExtension>true</IsAppExtension>
182180
<Project>{1B35BAEA-5666-408C-BED4-DB6114F3070E}</Project>
183181
<Name>SampleNotificationServiceExtension</Name>
182+
<IsAppExtension>true</IsAppExtension>
184183
<IsWatchApp>false</IsWatchApp>
185184
</ProjectReference>
186185
</ItemGroup>

sample/SampleNotificationServiceExtension/NotificationService.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
using System;
1+
// ==========================================================================
2+
// Notifo.io
3+
// ==========================================================================
4+
// Copyright (c) Sebastian Stehle
5+
// All rights reserved. Licensed under the MIT license.
6+
// ==========================================================================
7+
8+
using System;
29
using Foundation;
310
using Notifo.SDK;
411
using Sample.iOS.Shared;
@@ -9,31 +16,35 @@ namespace SampleNotificationServiceExtension
916
[Register("NotificationService")]
1017
public class NotificationService : UNNotificationServiceExtension
1118
{
12-
Action<UNNotificationContent> ContentHandler { get; set; }
13-
UNMutableNotificationContent BestAttemptContent { get; set; }
19+
public Action<UNNotificationContent> ContentHandler { get; set; }
1420

15-
protected NotificationService(IntPtr handle) : base(handle)
21+
public UNMutableNotificationContent BestAttemptContent { get; set; }
22+
23+
protected NotificationService(IntPtr handle)
24+
: base(handle)
1625
{
17-
// Note: this .ctor should not contain any initialization logic.
26+
// Note: this constructor should not contain any initialization logic.
1827
}
1928

2029
public override async void DidReceiveNotificationRequest(UNNotificationRequest request, Action<UNNotificationContent> contentHandler)
2130
{
2231
ContentHandler = contentHandler;
32+
33+
//Save the notification and create a mutable copy
2334
BestAttemptContent = (UNMutableNotificationContent)request.Content.MutableCopy();
2435

2536
NotifoIO.Current.SetNotificationHandler(new NotificationHandler());
2637

2738
await NotifoIO.DidReceiveNotificationRequestAsync(request, BestAttemptContent);
2839

40+
// Display the notification.
2941
ContentHandler(BestAttemptContent);
3042
}
3143

3244
public override void TimeWillExpire()
3345
{
3446
// Called just before the extension will be terminated by the system.
3547
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
36-
3748
ContentHandler(BestAttemptContent);
3849
}
3950
}

sdk/Notifo.SDK.FirebasePlugin/Notifo.SDK.FirebasePlugin.csproj

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,42 @@
2222
<Compile Remove="**\*.ios.cs" />
2323
</ItemGroup>
2424

25-
<ItemGroup Condition=" $(TargetFramework.StartsWith('monoandroid')) ">
26-
<None Include="**\*.netstandard.cs" />
27-
<Compile Include="**\*.android.cs" />
25+
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
26+
<Compile Include="**\*.netstandard.cs" />
27+
<None Include="**\*.android.cs" />
2828
<None Include="**\*.ios.cs" />
2929
</ItemGroup>
3030

31-
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) ">
32-
<Compile Include="**\*.netstandard.cs" />
33-
<None Include="**\*.android.cs" />
31+
<ItemGroup Condition="$(TargetFramework.StartsWith('monoandroid'))">
32+
<Compile Include="**\*.android.cs" />
33+
<None Include="**\*.netstandard.cs" />
3434
<None Include="**\*.ios.cs" />
3535
</ItemGroup>
3636

37-
<ItemGroup Condition=" $(TargetFramework.StartsWith('xamarinios')) ">
37+
<ItemGroup Condition="$(TargetFramework.StartsWith('xamarinios'))">
38+
<Compile Include="**\*.ios.cs" />
3839
<None Include="**\*.netstandard.cs" />
3940
<None Include="**\*.android.cs" />
40-
<Compile Include="**\*.ios.cs" />
41-
<PackageReference Include="Xamarin.Firebase.iOS.CloudMessaging" Version="8.10.0" />
42-
<PackageReference Include="Xamarin.Firebase.iOS.Installations" Version="8.10.0" />
43-
<PackageReference Include="Xamarin.Firebase.iOS.Core" Version="8.10.0" />
44-
<PackageReference Include="Xamarin.Firebase.iOS.InstanceID" Version="4.8.0" />
4541
</ItemGroup>
4642

47-
<ItemGroup>
48-
<PackageReference Include="Notifo.SDK" Version="1.3.0" />
49-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
50-
<PackageReference Include="Xamarin.Firebase.iOS.CloudMessaging" Version="8.10.0.1" />
51-
<PackageReference Include="Xamarin.Firebase.iOS.Core" Version="8.10.0.1" />
52-
<PackageReference Include="Xamarin.Firebase.iOS.Installations" Version="8.10.0.1" />
43+
<ItemGroup Condition="$(TargetFramework.StartsWith('xamarinios'))">
44+
<PackageReference Include="Xamarin.Firebase.iOS.CloudMessaging" Version="8.10.0.1" />
45+
<PackageReference Include="Xamarin.Firebase.iOS.Installations" Version="8.10.0.1" />
46+
<PackageReference Include="Xamarin.Firebase.iOS.Core" Version="8.10.0.1" />
47+
<PackageReference Include="Xamarin.Firebase.iOS.InstanceID" Version="4.8.0" />
48+
</ItemGroup>
49+
50+
<ItemGroup Condition="$(TargetFramework.StartsWith('monoandroid'))">
51+
<PackageReference Include="Xamarin.Firebase.Common" Version="120.0.0.5" />
52+
<PackageReference Include="Xamarin.Firebase.Messaging" Version="122.0.0.5" />
5353
</ItemGroup>
5454

5555
<ItemGroup>
56-
<ProjectReference Include="..\Notifo.SDK\Notifo.SDK.Core.csproj" />
56+
<PackageReference Include="Notifo.SDK" Version="1.3.0" />
57+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
5758
</ItemGroup>
5859

59-
<ItemGroup Condition="'$(TargetFramework)' == 'monoandroid12.0'">
60-
<PackageReference Include="Xamarin.Firebase.Common">
61-
<Version>120.0.0.5</Version>
62-
</PackageReference>
63-
<PackageReference Include="Xamarin.Firebase.Messaging">
64-
<Version>122.0.0.5</Version>
65-
</PackageReference>
60+
<ItemGroup>
61+
<ProjectReference Include="..\Notifo.SDK\Notifo.SDK.Core.csproj" />
6662
</ItemGroup>
6763
</Project>

sdk/Notifo.SDK/Notifo.SDK.Core.csproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
</ItemGroup>
3535

3636
<ItemGroup Condition=" $(TargetFramework.StartsWith('xamarinios')) ">
37+
<Compile Include="**\*.ios.cs" />
3738
<None Include="**\*.netstandard.cs" />
3839
<None Include="**\*.android.cs" />
39-
<Compile Include="**\*.ios.cs" />
4040
</ItemGroup>
4141

4242
<ItemGroup Condition=" $(TargetFramework.StartsWith('monoandroid')) ">
43-
<None Include="**\*.netstandard.cs" />
4443
<Compile Include="**\*.android.cs" />
44+
<None Include="**\*.netstandard.cs" />
4545
<None Include="**\*.ios.cs" />
4646
</ItemGroup>
4747

@@ -65,15 +65,11 @@
6565
</ItemGroup>
6666

6767
<ItemGroup Condition="'$(TargetFramework)' == 'xamarinios10'">
68-
<PackageReference Include="Serilog.Sinks.Xamarin">
69-
<Version>0.2.0.64</Version>
70-
</PackageReference>
68+
<PackageReference Include="Serilog.Sinks.Xamarin" Version="0.2.0.64" />
7169
</ItemGroup>
7270

7371
<ItemGroup Condition="'$(TargetFramework)' == 'monoandroid12.0'">
74-
<PackageReference Include="Serilog.Sinks.Xamarin">
75-
<Version>0.2.0.64</Version>
76-
</PackageReference>
72+
<PackageReference Include="Serilog.Sinks.Xamarin" Version="0.2.0.64" />
7773
</ItemGroup>
7874

7975
<ItemGroup>

sdk/Notifo.SDK/NotifoMobilePush/NotifoMobilePushImplementation.ios.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ partial void SetupPlatform()
3333
public INotifoMobilePush SetNotificationHandler(INotificationHandler? notificationHandler)
3434
{
3535
this.notificationHandler = notificationHandler;
36-
3736
return this;
3837
}
3938

@@ -194,7 +193,7 @@ private async Task<UNMutableNotificationContent> EnrichNotificationContentAsync(
194193
var allCategories = await UNUserNotificationCenter.Current.GetNotificationCategoriesAsync();
195194
if (allCategories != null)
196195
{
197-
foreach (UNNotificationCategory category in allCategories)
196+
foreach (var category in allCategories.OfType<UNNotificationCategory>())
198197
{
199198
if (category.Identifier != categoryId)
200199
{
@@ -211,16 +210,13 @@ private async Task<UNMutableNotificationContent> EnrichNotificationContentAsync(
211210

212211
UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet<UNNotificationCategory>(categories.ToArray()));
213212

214-
// without this call action buttons won't be added or updated
213+
// Without this call action buttons will not be added or updated
215214
_ = await UNUserNotificationCenter.Current.GetNotificationCategoriesAsync();
216215

217216
content.CategoryIdentifier = categoryId;
218217
}
219218

220-
if (content.Sound == null)
221-
{
222-
content.Sound = UNNotificationSound.Default;
223-
}
219+
content.Sound ??= UNNotificationSound.Default;
224220

225221
notificationHandler?.OnBuildNotification(content, notification);
226222

@@ -247,7 +243,7 @@ private async Task AddImageAsync(UNMutableNotificationContent content, UserNotif
247243
var attachmentUrl = new NSUrl(attachmentName, NSFileManager.DefaultManager.GetTemporaryDirectory());
248244

249245
// TODO: We copy the image twice. Really weird.
250-
NSFileManager.DefaultManager.Copy(NSUrl.FromFilename(imagePath), attachmentUrl, out var error);
246+
NSFileManager.DefaultManager.Copy(NSUrl.FromFilename(attachmentName), attachmentUrl, out var error);
251247

252248
if (error != null)
253249
{
@@ -261,9 +257,9 @@ private async Task AddImageAsync(UNMutableNotificationContent content, UserNotif
261257
new UNNotificationAttachmentOptions(),
262258
out error);
263259

264-
if (error != null)
260+
if (error != null || attachement == null)
265261
{
266-
NotifoIO.Current.RaiseError(error.LocalizedDescription, null, this);
262+
NotifoIO.Current.RaiseError(error?.LocalizedDescription ?? "Unknown Error", null, this);
267263
return;
268264
}
269265

0 commit comments

Comments
 (0)