Skip to content

Commit

Permalink
Updated sample
Browse files Browse the repository at this point in the history
  • Loading branch information
rdelrosario committed Aug 2, 2018
1 parent 3134023 commit 669e35c
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 79 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,21 @@ public override void OnCreate()
{
base.OnCreate();
RegisterActivityLifecycleCallbacks(this);


//Set the default notification channel for your app when running Android Oreo
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
//Change for your default notification channel id here
FirebasePushNotificationManager.DefaultNotificationChannelId = "DefaultChannel";

//Change for your default notification channel name here
FirebasePushNotificationManager.DefaultNotificationChannelName = "General";
}


//If debug you should reset the token each time.
#if DEBUG
#if DEBUG
FirebasePushNotificationManager.Initialize(this,new NotificationUserCategory[]
{
new NotificationUserCategory("message",new List<NotificationUserAction> {
Expand Down Expand Up @@ -64,16 +77,7 @@ public override void OnCreate()

};

//Set the default notification channel for your app when running Android Oreo
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
//Change for your default notification channel id here
FirebasePushNotificationManager.DefaultNotificationChannelId = "DefaultChannel";

//Change for your default notification channel name here
FirebasePushNotificationManager.DefaultNotificationChannelName = "General";
}



}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Plugin.CurrentActivity" version="1.0.1" targetFramework="monoandroid71" />
<package id="Plugin.FirebasePushNotification" version="2.3.0" targetFramework="monoandroid80" />
<package id="Plugin.FirebasePushNotification" version="2.3.5" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="26.0.2" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Annotations" version="26.0.2" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Compat" version="26.0.2" targetFramework="monoandroid80" />
Expand All @@ -18,12 +18,12 @@
<package id="Xamarin.Android.Support.v7.Palette" version="26.0.2" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="26.0.2" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="26.0.2" targetFramework="monoandroid80" />
<package id="Xamarin.Build.Download" version="0.4.7" targetFramework="monoandroid80" />
<package id="Xamarin.Firebase.Common" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.Firebase.Iid" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.Firebase.Messaging" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.Build.Download" version="0.4.9" targetFramework="monoandroid80" />
<package id="Xamarin.Firebase.Common" version="60.1142.1" targetFramework="monoandroid80" />
<package id="Xamarin.Firebase.Iid" version="60.1142.1" targetFramework="monoandroid80" />
<package id="Xamarin.Firebase.Messaging" version="60.1142.1" targetFramework="monoandroid80" />
<package id="Xamarin.Forms" version="2.5.0.122203" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Base" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Basement" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Tasks" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Base" version="60.1142.1" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Basement" version="60.1142.1" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Tasks" version="60.1142.1" targetFramework="monoandroid80" />
</packages>
20 changes: 2 additions & 18 deletions samples/FirebasePushSample/FirebasePushSample.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
#if DEBUG
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken, FirebaseTokenType.Sandbox);
#endif
#if RELEASE
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken,FirebaseTokenType.Production);
#endif
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);

}

Expand All @@ -72,19 +67,8 @@ public override void DidReceiveRemoteNotification(UIApplication application, NSD
FirebasePushNotificationManager.DidReceiveMessage(userInfo);
// Do your magic to handle the notification data
System.Console.WriteLine(userInfo);
}

public override void OnActivated(UIApplication uiApplication)
{
FirebasePushNotificationManager.Connect();
base.OnActivated(uiApplication);

}
public override void DidEnterBackground(UIApplication application)
{
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
FirebasePushNotificationManager.Disconnect();
completionHandler(UIBackgroundFetchResult.NewData);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<MtouchExtraArgs>--registrar:static</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
Expand All @@ -38,6 +39,7 @@
<MtouchLink>None</MtouchLink>
<MtouchArch>i386, x86_64</MtouchArch>
<ConsolePause>false</ConsolePause>
<MtouchExtraArgs>--registrar:static</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -122,22 +124,22 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Firebase.Analytics, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5\lib\Xamarin.iOS10\Firebase.Analytics.dll</HintPath>
<HintPath>..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5.1\lib\Xamarin.iOS10\Firebase.Analytics.dll</HintPath>
</Reference>
<Reference Include="Firebase.CloudMessaging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.4.1\lib\Xamarin.iOS10\Firebase.CloudMessaging.dll</HintPath>
<HintPath>..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.8.1\lib\Xamarin.iOS10\Firebase.CloudMessaging.dll</HintPath>
</Reference>
<Reference Include="Firebase.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Firebase.iOS.Core.4.0.13\lib\Xamarin.iOS10\Firebase.Core.dll</HintPath>
<HintPath>..\packages\Xamarin.Firebase.iOS.Core.4.0.13.1\lib\Xamarin.iOS10\Firebase.Core.dll</HintPath>
</Reference>
<Reference Include="Firebase.InstanceID, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Firebase.iOS.InstanceID.2.0.8\lib\Xamarin.iOS10\Firebase.InstanceID.dll</HintPath>
</Reference>
<Reference Include="Plugin.FirebasePushNotification, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.0\lib\Xamarin.iOS10\Plugin.FirebasePushNotification.dll</HintPath>
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.5\lib\Xamarin.iOS10\Plugin.FirebasePushNotification.dll</HintPath>
</Reference>
<Reference Include="Plugin.FirebasePushNotification.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.0\lib\Xamarin.iOS10\Plugin.FirebasePushNotification.Abstractions.dll</HintPath>
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.5\lib\Xamarin.iOS10\Plugin.FirebasePushNotification.Abstractions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -174,15 +176,15 @@
<Error Condition="!Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Forms.2.5.0.122203\build\netstandard1.0\Xamarin.Forms.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.5.0.122203\build\netstandard1.0\Xamarin.Forms.props'))" />
<Error Condition="!Exists('..\packages\Xamarin.Forms.2.5.0.122203\build\netstandard1.0\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.5.0.122203\build\netstandard1.0\Xamarin.Forms.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.Core.4.0.13\build\Xamarin.Firebase.iOS.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.Core.4.0.13\build\Xamarin.Firebase.iOS.Core.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.InstanceID.2.0.8\build\Xamarin.Firebase.iOS.InstanceID.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.InstanceID.2.0.8\build\Xamarin.Firebase.iOS.InstanceID.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5\build\Xamarin.Firebase.iOS.Analytics.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5\build\Xamarin.Firebase.iOS.Analytics.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.4.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.4.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.Core.4.0.13.1\build\Xamarin.Firebase.iOS.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.Core.4.0.13.1\build\Xamarin.Firebase.iOS.Core.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5.1\build\Xamarin.Firebase.iOS.Analytics.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5.1\build\Xamarin.Firebase.iOS.Analytics.targets'))" />
<Error Condition="!Exists('..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.8.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.8.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets'))" />
</Target>
<Import Project="..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.7\build\Xamarin.Build.Download.targets')" />
<Import Project="..\packages\Xamarin.Forms.2.5.0.122203\build\netstandard1.0\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.5.0.122203\build\netstandard1.0\Xamarin.Forms.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.Core.4.0.13\build\Xamarin.Firebase.iOS.Core.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.Core.4.0.13\build\Xamarin.Firebase.iOS.Core.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.InstanceID.2.0.8\build\Xamarin.Firebase.iOS.InstanceID.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.InstanceID.2.0.8\build\Xamarin.Firebase.iOS.InstanceID.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5\build\Xamarin.Firebase.iOS.Analytics.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5\build\Xamarin.Firebase.iOS.Analytics.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.4.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.4.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.Core.4.0.13.1\build\Xamarin.Firebase.iOS.Core.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.Core.4.0.13.1\build\Xamarin.Firebase.iOS.Core.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5.1\build\Xamarin.Firebase.iOS.Analytics.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.Analytics.4.0.5.1\build\Xamarin.Firebase.iOS.Analytics.targets')" />
<Import Project="..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.8.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets" Condition="Exists('..\packages\Xamarin.Firebase.iOS.CloudMessaging.2.0.8.1\build\Xamarin.Firebase.iOS.CloudMessaging.targets')" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Plugin.FirebasePushNotification" version="2.3.0" targetFramework="xamarinios10" />
<package id="Plugin.FirebasePushNotification" version="2.3.5" targetFramework="xamarinios10" />
<package id="Xamarin.Build.Download" version="0.4.7" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.Analytics" version="4.0.5" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.CloudMessaging" version="2.0.4.1" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.Core" version="4.0.13" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.Analytics" version="4.0.5.1" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.CloudMessaging" version="2.0.8.1" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.Core" version="4.0.13.1" targetFramework="xamarinios10" />
<package id="Xamarin.Firebase.iOS.InstanceID" version="2.0.8" targetFramework="xamarinios10" />
<package id="Xamarin.Forms" version="2.5.0.122203" targetFramework="xamarinios10" />
</packages>
17 changes: 17 additions & 0 deletions samples/FirebasePushSample/FirebasePushSample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ protected override void OnStart()

}
};

CrossFirebasePushNotification.Current.OnNotificationAction += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Action");

if (!string.IsNullOrEmpty(p.Identifier))
{
System.Diagnostics.Debug.WriteLine($"ActionId: {p.Identifier}");
foreach (var data in p.Data)
{
System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}");
}

}

};

CrossFirebasePushNotification.Current.OnNotificationDeleted += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Dismissed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Plugin.FirebasePushNotification, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.0\lib\netstandard1.0\Plugin.FirebasePushNotification.dll</HintPath>
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.5\lib\netstandard1.0\Plugin.FirebasePushNotification.dll</HintPath>
</Reference>
<Reference Include="Plugin.FirebasePushNotification.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.0\lib\netstandard1.0\Plugin.FirebasePushNotification.Abstractions.dll</HintPath>
<HintPath>..\packages\Plugin.FirebasePushNotification.2.3.5\lib\netstandard1.0\Plugin.FirebasePushNotification.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.2.5.0.122203\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Core.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Plugin.FirebasePushNotification" version="2.3.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Plugin.FirebasePushNotification" version="2.3.5" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="System.Collections" version="4.3.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
Expand Down

0 comments on commit 669e35c

Please sign in to comment.