Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xamarin way to use OSRemoteNotificationReceivedHandler #381

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using AndroidX.Core.App;

namespace Com.OneSignal.Android
{
public abstract class NotificationExtenderBase : Java.Lang.Object, NotificationCompat.IExtender
{
public abstract NotificationCompat.Builder Extend(NotificationCompat.Builder builder);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Android.Content;

namespace Com.OneSignal.Android
{
public abstract class OSRemoteNotificationReceivedBase : Java.Lang.Object, OneSignal.IOSRemoteNotificationReceivedHandler
{
public abstract void RemoteNotificationReceived(Context ctx, OSNotificationReceivedEvent ev);
}
}
10 changes: 8 additions & 2 deletions OneSignal.Android.Binding/OneSignal.Android.Binding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AssemblyName>OneSignal.Android.Binding</AssemblyName>
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
tmijieux marked this conversation as resolved.
Show resolved Hide resolved
<AndroidSdkBuildToolsVersion Condition="'$(AndroidSdkBuildToolsVersion)' == ''">28.0.3</AndroidSdkBuildToolsVersion>
<AndroidTlsProvider></AndroidTlsProvider>
<AndroidClassParser>class-parse</AndroidClassParser>
Expand Down Expand Up @@ -43,6 +43,9 @@
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
</ItemGroup>
<ItemGroup>
<Compile Include="Additions\*.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="Additions\AboutAdditions.txt" />
<None Include="Jars\AboutJars.txt" />
Expand All @@ -55,5 +58,8 @@
<ItemGroup>
<LibraryProjectZip Include="Jars\onesignal-release.aar" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.12.0.2" />
</ItemGroup>
tmijieux marked this conversation as resolved.
Show resolved Hide resolved
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
</Project>
</Project>
2 changes: 1 addition & 1 deletion OneSignal.Android.Binding/Transforms/EnumFields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
to an enum called Android.Support.V4.App.FragmentTagType with values
Id, Name, and Tag.

<mapping clr-enum-type="Android.Support.V4.App.FragmentTagType" jni-class="android/support/v4/app/FragmentActivity$FragmentTag">
<field clr-name="Id" jni-name="Fragment_id" value="1" />
<field clr-name="Name" jni-name="Fragment_name" value="0" />
Expand Down
17 changes: 17 additions & 0 deletions OneSignalSDK.Xamarin.Android/NotificationExtensionAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Diagnostics;
using Android.App;
using Android.Content;

namespace Com.OneSignal.Android
{
[Serializable]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class NotificationExtensionAttribute : Attribute, Java.Interop.IJniNameProviderAttribute
tmijieux marked this conversation as resolved.
Show resolved Hide resolved
{
public string Name { get; set; }
public NotificationExtensionAttribute()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<OutputType>Library</OutputType>
<RootNamespace>OneSignalSDK.Xamarin</RootNamespace>
<AssemblyName>OneSignalSDK.Xamarin</AssemblyName>
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidTlsProvider>
Expand Down Expand Up @@ -284,6 +284,7 @@
</Compile>
<Compile Include="Utilities\NativeConversion.cs" />
<Compile Include="OneSignalCallbacks.cs" />
<Compile Include="NotificationExtensionAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OneSignal.Android.Binding\OneSignal.Android.Binding.csproj">
Expand Down Expand Up @@ -371,4 +372,4 @@
<Import Project="..\packages\Xamarin.Jetbrains.Annotations.22.0.0.2\build\monoandroid90\Xamarin.Jetbrains.Annotations.targets" Condition="Exists('..\packages\Xamarin.Jetbrains.Annotations.22.0.0.2\build\monoandroid90\Xamarin.Jetbrains.Annotations.targets')" />
<Import Project="..\packages\Xamarin.Kotlin.StdLib.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.targets" Condition="Exists('..\packages\Xamarin.Kotlin.StdLib.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.targets')" />
<Import Project="..\packages\Xamarin.Kotlin.StdLib.Common.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.Common.targets" Condition="Exists('..\packages\Xamarin.Kotlin.StdLib.Common.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.Common.targets')" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputType>Library</OutputType>
<RootNamespace>OneSignalApp.Sample.Droid</RootNamespace>
<AssemblyName>OneSignalApp.Sample.Droid</AssemblyName>
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
Expand Down Expand Up @@ -392,4 +392,4 @@
<Import Project="..\..\packages\Xamarin.Kotlin.StdLib.Jdk7.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.Jdk7.targets" Condition="Exists('..\..\packages\Xamarin.Kotlin.StdLib.Jdk7.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.Jdk7.targets')" />
<Import Project="..\..\packages\Xamarin.Kotlin.StdLib.Jdk8.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.Jdk8.targets" Condition="Exists('..\..\packages\Xamarin.Kotlin.StdLib.Jdk8.1.5.31.2\build\monoandroid90\Xamarin.Kotlin.StdLib.Jdk8.targets')" />
<Import Project="..\..\packages\Xamarin.Build.Download.0.11.2\build\Xamarin.Build.Download.targets" Condition="Exists('..\..\packages\Xamarin.Build.Download.0.11.2\build\Xamarin.Build.Download.targets')" />
</Project>
</Project>