Skip to content

Commit

Permalink
feat: Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Mar 11, 2024
1 parent 6a53693 commit 0193cf3
Show file tree
Hide file tree
Showing 66 changed files with 1,859 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
groups:
all:
patterns:
- "*"
40 changes: 40 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build, test and publish
on:
push:
branches:
- main
paths:
- 'src/**'
- '.github/workflows/**'

jobs:
buind-test-publish:
name: Build, test and publish
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install workloads
run: dotnet workload install maui

- name: Install Tizen workload on macOS / Linux
if: runner.os != 'Windows'
run: curl -sSL https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.sh | sudo bash

- name: Install Tizen workload on Windows
if: runner.os == 'Windows'
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
./workload-install.ps1
- name: Build
run: dotnet build src/libs/Maui.InAppReviews
--configuration Release

- name: Publish
run: dotnet nuget push
**.nupkg
--skip-duplicate
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_KEY }}
33 changes: 33 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and test
on:
pull_request:
branches:
- main
paths:
- 'src/**'
- '.github/workflows/**'

jobs:
buind-test:
name: Build, test and publish
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install workloads
run: dotnet workload install maui

- name: Install Tizen workload on macOS / Linux
if: runner.os != 'Windows'
run: curl -sSL https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.sh | sudo bash

- name: Install Tizen workload on Windows
if: runner.os == 'Windows'
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
./workload-install.ps1
- name: Build
run: dotnet build src/libs/Maui.InAppReviews
--configuration Release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/.idea
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Oscore
Copyright (c) 2024 Oscore Ltd. and James Montemagno

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
73 changes: 73 additions & 0 deletions Maui.InAppReviews.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32314.265
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{94FE90BF-FA05-46C6-A207-6E454A236659}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
README.md = README.md
LICENSE = LICENSE
.github\dependabot.yml = .github\dependabot.yml
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{928D4422-05CE-4AC2-89B0-31060889AE6A}"
ProjectSection(SolutionItems) = preProject
src\libs\Directory.Build.props = src\libs\Directory.Build.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maui.InAppReviews", "src\libs\Maui.InAppReviews\Maui.InAppReviews.csproj", "{8E7AE677-AD62-4FFE-ACBF-0F1A947ACDDB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{4746EB5B-E37C-40F0-8CA6-7D03185F5370}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maui.InAppReviews.SampleApp", "sample\Maui.InAppReviews.SampleApp.csproj", "{542C62E2-8E4A-4FA0-8052-6DCF4A9C7B1A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8DEF204E-ED5E-45A8-B021-47F6588890F4}"
ProjectSection(SolutionItems) = preProject
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
.github\workflows\pr.yml = .github\workflows\pr.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "helpers", "helpers", "{E9A82491-47A5-4EFC-9AAA-D7E5382A22DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrimmingHelper", "src\helpers\TrimmingHelper\TrimmingHelper.csproj", "{F464A23B-B245-4687-BFB3-0DB3FEEAC38B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrimmingHelperApp", "src\helpers\TrimmingHelperApp\TrimmingHelperApp.csproj", "{2073350E-1781-4C08-A24E-CD57F2466B03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8E7AE677-AD62-4FFE-ACBF-0F1A947ACDDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E7AE677-AD62-4FFE-ACBF-0F1A947ACDDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E7AE677-AD62-4FFE-ACBF-0F1A947ACDDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E7AE677-AD62-4FFE-ACBF-0F1A947ACDDB}.Release|Any CPU.Build.0 = Release|Any CPU
{542C62E2-8E4A-4FA0-8052-6DCF4A9C7B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{542C62E2-8E4A-4FA0-8052-6DCF4A9C7B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{542C62E2-8E4A-4FA0-8052-6DCF4A9C7B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{542C62E2-8E4A-4FA0-8052-6DCF4A9C7B1A}.Release|Any CPU.Build.0 = Release|Any CPU
{F464A23B-B245-4687-BFB3-0DB3FEEAC38B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F464A23B-B245-4687-BFB3-0DB3FEEAC38B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F464A23B-B245-4687-BFB3-0DB3FEEAC38B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F464A23B-B245-4687-BFB3-0DB3FEEAC38B}.Release|Any CPU.Build.0 = Release|Any CPU
{2073350E-1781-4C08-A24E-CD57F2466B03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2073350E-1781-4C08-A24E-CD57F2466B03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2073350E-1781-4C08-A24E-CD57F2466B03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2073350E-1781-4C08-A24E-CD57F2466B03}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8E7AE677-AD62-4FFE-ACBF-0F1A947ACDDB} = {928D4422-05CE-4AC2-89B0-31060889AE6A}
{542C62E2-8E4A-4FA0-8052-6DCF4A9C7B1A} = {4746EB5B-E37C-40F0-8CA6-7D03185F5370}
{8DEF204E-ED5E-45A8-B021-47F6588890F4} = {94FE90BF-FA05-46C6-A207-6E454A236659}
{F464A23B-B245-4687-BFB3-0DB3FEEAC38B} = {E9A82491-47A5-4EFC-9AAA-D7E5382A22DB}
{2073350E-1781-4C08-A24E-CD57F2466B03} = {E9A82491-47A5-4EFC-9AAA-D7E5382A22DB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1493AEE4-9211-46E9-BFE6-8F629EAC5693}
EndGlobalSection
EndGlobal
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# Maui.Android.InAppReviews
NuGet package that implementing native Android In-App Reviews within a MAUI application with debugging capabilities
# Maui.InAppReviews

[![Nuget package](https://img.shields.io/nuget/vpre/Oscore.Maui.InAppReviews)](https://www.nuget.org/packages/Oscore.Maui.InAppReviews/)
[![CI/CD](https://github.com/oscoreio/Maui.InAppReviews/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/oscoreio/Maui.InAppReviews/actions/workflows/dotnet.yml)
[![License: MIT](https://img.shields.io/github/license/oscoreio/Maui.InAppReviews)](https://github.com/oscoreio/Maui.InAppReviews/blob/main/LICENSE)

NuGet package that implementing native In-App Reviews for MAUI with debugging capabilities.
![InAppReviews](https://developer.android.com/static/images/google/play/in-app-review/iar-flow.jpg)

In-app reviews supported on Android 5.0 (API level 21) & iOS 10.3+ & Windows devices.
It can return ReviewStatus.NotSupported, in this case you can use [AppStoreInfo](https://github.com/oscoreio/Maui.AppStoreInfo) to open review page in the store.

# Usage
- Add NuGet package to your project:
```xml
<PackageReference Include="Oscore.Maui.InAppReviews" Version="1.0.0" />
```
- Add the following to your `MauiProgram.cs` `CreateMauiApp` method:
```diff
builder
.UseMauiApp<App>()
+ .UseInAppReviews()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
```

```cs
ReviewStatus status = await InAppReview.Current.RequestAsync();
```


# Links
- https://developer.android.com/guide/playcore/in-app-review
- https://github.com/jamesmontemagno/StoreReviewPlugin
- [Requesting Reviews with iOS 10.3’s SKStoreReviewController](https://devblogs.microsoft.com/xamarin/requesting-reviews-ios-10-3s-skstorereviewcontroller/?WT.mc_id=friends-0000-jamont)
- [In-app reviews for your Android apps](https://devblogs.microsoft.com/xamarin/android-in-app-reviews/?WT.mc_id=friends-0000-jamont)

### Android code shrinker (Proguard & r8)

If you use the plugin with `Link SDK assemblies only`/`Link all`, you have to do the following:

1. Create a `proguard.txt` file in your android project and add the following:

```
-keep class com.google.android.play.core.common.PlayCoreDialogWrapperActivity
-keep class com.google.android.play.core.review.** { *; }
-keep class com.google.android.play.core.tasks.** { *; }
```

2. Include it to your project
3. Properties > Build Action > ProguardConfiguration
4. Go to you Android project options and set your `Code Shrinker` to `ProGuard` or `r8`

### Testing & Debugging issues

#### iOS

* You cannot submit a review on iOS while developing, but the review popup dialog displays in your simulator/device.
* However, when you download the app from Testflight, the popup dialog does not display at all, as [mentioned here](https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview):
> When you call this method while your app is still in development mode, a rating/review request view is always displayed so that you can test the user interface and experience. However, this method has no effect when you call it in an app that you distribute using TestFlight."
#### Android

* Unlike iOS, you cannot see the review popup dialog while developing or if you distribute it manually. As you can [see here](https://developer.android.com/guide/playcore/in-app-review/test), you have to download the app from the Play Store to see the popup. I recommend using Android Play Store's [“Internal App Sharing”](https://play.google.com/console/about/internalappsharing/) feature to test.
* Occasionally, some devices may not show the popup at all as [seen here](https://github.com/jamesmontemagno/StoreReviewPlugin/pull/27#issuecomment-877410136). One way to test whether your device is affected by it, is by downloading [this game that uses v3.1 of this nuget, target SDK version 30, target framework v11.0](https://play.google.com/store/apps/details?id=com.tfp.numberbomb) and win the game once to see the popup. Additionally, you can debug the error using adb locat, as you can [see here](https://github.com/jamesmontemagno/StoreReviewPlugin/issues/26#issue-940942211)
* The [most common issue/crash type](https://github.com/jamesmontemagno/StoreReviewPlugin/issues/20) is that developers release the app in the release configuration but they only test in the debug configuration. They do not realize that they have set Linker behavior to `Link SDK assemblies only`/`Link all`, and did not follow the proguard steps mentioned above
Binary file added assets/nuget_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions sample/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Application
x:Class="Maui.InAppReviews.SampleApp.App"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:local="clr-namespace:Maui.InAppReviews.SampleApp"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
11 changes: 11 additions & 0 deletions sample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Maui.InAppReviews.SampleApp;

public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
15 changes: 15 additions & 0 deletions sample/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
Shell.FlyoutBehavior="Disabled"
Title="Maui.InAppReviews.SampleApp"
x:Class="Maui.InAppReviews.SampleApp.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:local="clr-namespace:Maui.InAppReviews.SampleApp"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

<ShellContent
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage"
Title="Home" />

</Shell>
9 changes: 9 additions & 0 deletions sample/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Maui.InAppReviews.SampleApp;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
19 changes: 19 additions & 0 deletions sample/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="Maui.InAppReviews.SampleApp.MainPage"
x:DataType="sampleApp:MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:sampleApp="clr-namespace:Maui.InAppReviews.SampleApp"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

<ScrollView>
<VerticalStackLayout
HorizontalOptions="Center"
Padding="30,0"
Spacing="25"
VerticalOptions="Center">
<Button Command="{Binding RequestReviewCommand}" Text="Request Review" />
</VerticalStackLayout>
</ScrollView>

</ContentPage>
21 changes: 21 additions & 0 deletions sample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using CommunityToolkit.Mvvm.Input;

namespace Maui.InAppReviews.SampleApp;

public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
BindingContext = this;
}

[RelayCommand]
private async Task RequestReview()
{
ReviewStatus status = await InAppReview.Current.RequestAsync();

await DisplayAlert("Review Status", status.ToString(), "Ok");
}
}

Loading

0 comments on commit 0193cf3

Please sign in to comment.