From ca8861072840a863ab57fd8c29a8c0d0b1df7898 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 29 四月 2021 16:42:19 +0800 Subject: [PATCH] 2021-04-29 1.Google Play极光推送库 --- JPushGP.Droid/Additions/AboutAdditions.txt | 48 +++ JPushGP.Droid/Jars/jpush-android-4.0.6-google_play.jar | 0 JPushGP.Droid/Jars/AboutJars.txt | 24 + .gitignore | 215 +++++++++++++- JPushGP.Droid/Properties/AssemblyInfo.cs | 26 + JPushGP.Droid/Transforms/Metadata.xml | 10 Xamarin.Android集成参考/JPush/JPushService.cs | 11 JPushGP.Droid/JPushGP.Droid.csproj | 73 +++++ JPushGP.Droid/Libs/arm64-v8a/libjcore278.so | 0 JPushGP.Droid/Libs/armeabi/libjcore278.so | 0 JPushGP.Droid/Transforms/EnumFields.xml | 15 + README.md | 6 Xamarin.Android集成参考/JPush/JPushReceiver.cs | 208 ++++++++++++++ JPushGP.Droid/Transforms/EnumMethods.xml | 14 + JPushGP.Droid/Jars/jcore-android-2.7.8-google_play.jar | 0 Xamarin.Android集成参考/AndroidManifest.xml | 131 +++++++++ JPushGP.Droid/Libs/armeabi-v7a/libjcore278.so | 0 17 files changed, 755 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index a3cd143..eb10cfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,189 @@ -# Xcode -# -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate - -# CocoaPods -# -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control -# -# Pods/ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +.vs/ +packages/ +.DS_Store + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +*.pubxml + +# NuGet Packages +packages/* +*.nupkg +## TODO: If the tool you use requires repositories.config +## uncomment the next line +#!packages/repositories.config + +# Enable "build/" folder in the NuGet Packages folder since +# NuGet packages use it for MSBuild targets. +# This line needs to be after the ignore of the build folder +# (and the packages folder if the line above has been uncommented) +!packages/build/ + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ diff --git a/JPushGP.Droid/Additions/AboutAdditions.txt b/JPushGP.Droid/Additions/AboutAdditions.txt new file mode 100644 index 0000000..c240307 --- /dev/null +++ b/JPushGP.Droid/Additions/AboutAdditions.txt @@ -0,0 +1,48 @@ +锘緼dditions allow you to add arbitrary C# to the generated classes +before they are compiled. This can be helpful for providing convenience +methods or adding pure C# classes. + +== Adding Methods to Generated Classes == + +Let's say the library being bound has a Rectangle class with a constructor +that takes an x and y position, and a width and length size. It will look like +this: + +public partial class Rectangle +{ + public Rectangle (int x, int y, int width, int height) + { + // JNI bindings + } +} + +Imagine we want to add a constructor to this class that takes a Point and +Size structure instead of 4 ints. We can add a new file called Rectangle.cs +with a partial class containing our new method: + +public partial class Rectangle +{ + public Rectangle (Point location, Size size) : + this (location.X, location.Y, size.Width, size.Height) + { + } +} + +At compile time, the additions class will be added to the generated class +and the final assembly will a Rectangle class with both constructors. + + +== Adding C# Classes == + +Another thing that can be done is adding fully C# managed classes to the +generated library. In the above example, let's assume that there isn't a +Point class available in Java or our library. The one we create doesn't need +to interact with Java, so we'll create it like a normal class in C#. + +By adding a Point.cs file with this class, it will end up in the binding library: + +public class Point +{ + public int X { get; set; } + public int Y { get; set; } +} \ No newline at end of file diff --git a/JPushGP.Droid/JPushGP.Droid.csproj b/JPushGP.Droid/JPushGP.Droid.csproj new file mode 100644 index 0000000..111aac6 --- /dev/null +++ b/JPushGP.Droid/JPushGP.Droid.csproj @@ -0,0 +1,73 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7247C19B-8277-4695-A05D-9F3CDF14877F}</ProjectGuid> + <ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <TemplateGuid>{77efb91c-a7e9-4b0e-a7c5-31eeec3c6d46}</TemplateGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>JPushGP.Droid</RootNamespace> + <AssemblyName>JPushGP.Droid</AssemblyName> + <FileAlignment>512</FileAlignment> + <Deterministic>True</Deterministic> + <TargetFrameworkVersion>v9.0</TargetFrameworkVersion> + <AndroidClassParser>class-parse</AndroidClassParser> + <AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget> + <RestoreProjectStyle>PackageReference</RestoreProjectStyle> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>portable</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>portable</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Mono.Android" /> + <Reference Include="System" /> + <Reference Include="System.Core" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Jars\AboutJars.txt" /> + <None Include="Additions\AboutAdditions.txt" /> + </ItemGroup> + <ItemGroup> + <TransformFile Include="Transforms\Metadata.xml" /> + <TransformFile Include="Transforms\EnumFields.xml" /> + <TransformFile Include="Transforms\EnumMethods.xml" /> + </ItemGroup> + <ItemGroup> + <EmbeddedJar Include="Jars\jcore-android-2.7.8-google_play.jar" /> + <EmbeddedJar Include="Jars\jpush-android-4.0.6-google_play.jar" /> + </ItemGroup> + <ItemGroup> + <EmbeddedNativeLibrary Include="Libs\armeabi-v7a\libjcore278.so" /> + <EmbeddedNativeLibrary Include="Libs\arm64-v8a\libjcore278.so" /> + <EmbeddedNativeLibrary Include="Libs\armeabi\libjcore278.so" /> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file diff --git a/JPushGP.Droid/Jars/AboutJars.txt b/JPushGP.Droid/Jars/AboutJars.txt new file mode 100644 index 0000000..c359b62 --- /dev/null +++ b/JPushGP.Droid/Jars/AboutJars.txt @@ -0,0 +1,24 @@ +锘縏his directory is for Android .jars. + +There are 2 types of jars that are supported: + +== Input Jar == + +This is the jar that bindings should be generated for. + +For example, if you were binding the Google Maps library, this would +be Google's "maps.jar". + +Set the build action for these jars in the properties page to "InputJar". + + +== Reference Jars == + +These are jars that are referenced by the input jar. C# bindings will +not be created for these jars. These jars will be used to resolve +types used by the input jar. + +NOTE: Do not add "android.jar" as a reference jar. It will be added automatically +based on the Target Framework selected. + +Set the build action for these jars in the properties page to "ReferenceJar". \ No newline at end of file diff --git a/JPushGP.Droid/Jars/jcore-android-2.7.8-google_play.jar b/JPushGP.Droid/Jars/jcore-android-2.7.8-google_play.jar new file mode 100644 index 0000000..ffa5caf --- /dev/null +++ b/JPushGP.Droid/Jars/jcore-android-2.7.8-google_play.jar Binary files differ diff --git a/JPushGP.Droid/Jars/jpush-android-4.0.6-google_play.jar b/JPushGP.Droid/Jars/jpush-android-4.0.6-google_play.jar new file mode 100644 index 0000000..315ba0f --- /dev/null +++ b/JPushGP.Droid/Jars/jpush-android-4.0.6-google_play.jar Binary files differ diff --git a/JPushGP.Droid/Libs/arm64-v8a/libjcore278.so b/JPushGP.Droid/Libs/arm64-v8a/libjcore278.so new file mode 100644 index 0000000..0815869 --- /dev/null +++ b/JPushGP.Droid/Libs/arm64-v8a/libjcore278.so Binary files differ diff --git a/JPushGP.Droid/Libs/armeabi-v7a/libjcore278.so b/JPushGP.Droid/Libs/armeabi-v7a/libjcore278.so new file mode 100644 index 0000000..729252f --- /dev/null +++ b/JPushGP.Droid/Libs/armeabi-v7a/libjcore278.so Binary files differ diff --git a/JPushGP.Droid/Libs/armeabi/libjcore278.so b/JPushGP.Droid/Libs/armeabi/libjcore278.so new file mode 100644 index 0000000..f26cbcd --- /dev/null +++ b/JPushGP.Droid/Libs/armeabi/libjcore278.so Binary files differ diff --git a/JPushGP.Droid/Properties/AssemblyInfo.cs b/JPushGP.Droid/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ad566be --- /dev/null +++ b/JPushGP.Droid/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Android.App; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle ("JPushGP.Droid")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("JPushGP.Droid")] +[assembly: AssemblyCopyright ("Copyright 漏 2021")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] +[assembly: ComVisible (false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +[assembly: AssemblyVersion ("1.0.1.0")] +[assembly: AssemblyFileVersion ("1.0.1.0")] diff --git a/JPushGP.Droid/Transforms/EnumFields.xml b/JPushGP.Droid/Transforms/EnumFields.xml new file mode 100644 index 0000000..e4a0f89 --- /dev/null +++ b/JPushGP.Droid/Transforms/EnumFields.xml @@ -0,0 +1,15 @@ +锘�<?xml version="1.0" encoding="UTF-8"?> +<enum-field-mappings> + <!-- + This example converts the constants Fragment_id, Fragment_name, + 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 jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType"> + <field jni-name="Fragment_name" clr-name="Name" value="0" /> + <field jni-name="Fragment_id" clr-name="Id" value="1" /> + <field jni-name="Fragment_tag" clr-name="Tag" value="2" /> + </mapping> + --> +</enum-field-mappings> \ No newline at end of file diff --git a/JPushGP.Droid/Transforms/EnumMethods.xml b/JPushGP.Droid/Transforms/EnumMethods.xml new file mode 100644 index 0000000..6ff109b --- /dev/null +++ b/JPushGP.Droid/Transforms/EnumMethods.xml @@ -0,0 +1,14 @@ +锘�<?xml version="1.0" encoding="UTF-8"?> +<enum-method-mappings> + <!-- + This example changes the Java method: + android.support.v4.app.Fragment.SavedState.writeToParcel (int flags) + to be: + android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags) + when bound in C#. + + <mapping jni-class="android/support/v4/app/Fragment.SavedState"> + <method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" /> + </mapping> + --> +</enum-method-mappings> \ No newline at end of file diff --git a/JPushGP.Droid/Transforms/Metadata.xml b/JPushGP.Droid/Transforms/Metadata.xml new file mode 100644 index 0000000..d091d82 --- /dev/null +++ b/JPushGP.Droid/Transforms/Metadata.xml @@ -0,0 +1,10 @@ +锘�<?xml version="1.0" encoding="UTF-8"?> +<metadata> + <!-- + This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask: + <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" /> + + This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground: + <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" /> + --> +</metadata> \ No newline at end of file diff --git a/README.md b/README.md index 46c228a..71c4787 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,9 @@ Google Play鏋佸厜鎺ㄩ�佸簱 + //璁剧疆鏋佸厜璋冭瘯妯″紡锛屼负false鏃跺彧鎵撳嵃璀﹀憡淇℃伅 + CN.Jpush.Android.Api.JPushInterface.SetDebugMode(false); + CN.Jpush.Android.Api.JPushInterface.Init (this); + + //鍏跺畠鍙傝�僗amarin.Android闆嗘垚鍙傝�冮噷闈㈡枃浠� + diff --git "a/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/AndroidManifest.xml" "b/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/AndroidManifest.xml" new file mode 100644 index 0000000..cb0a90f --- /dev/null +++ "b/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/AndroidManifest.xml" @@ -0,0 +1,131 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202104011" android:versionName="1.2.202104011" package="com.hdl.onpro"> + <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="26" /> + <!-- 鍙瀵硅鏉冮檺--> + <uses-permission android:name="android.permission.CAMERA" /> + <uses-feature android:name="android.hardware.camera" /> + <uses-feature android:name="android.hardware.camera.autofocus" /> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.VIBRATE" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.RECORD_AUDIO" /> + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> + <!-- 瀹氫綅鏉冮檺--> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <!-- 鎷嶇収鏉冮檺 --> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.CAMERA" /> + <!-- 鍦ㄥ畨鍗揚鐗堟湰涔嬪悗锛屽繀椤昏鎺堜簣FOREGROUND_SERVICE鏉冮檺锛屾墠鑳藉浣跨敤鍓嶅彴鏈嶅姟 --> + <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> + <!-- 鎾斁鏈湴闊充箰鏉冮檺--> + <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <!--鏋佸厜鎺ㄩ�� Required 涓�浜涚郴缁熻姹傜殑鏉冮檺锛屽璁块棶缃戠粶绛�--> + <!-- Required 涓�浜涚郴缁熻姹傜殑鏉冮檺锛屽璁块棶缃戠粶绛�--> + <permission android:name="com.hdl.onpro.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> + <!-- Required --> + <uses-permission android:name="com.hdl.onpro.permission.JPUSH_MESSAGE" /> + <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> + <uses-permission android:name="android.permission.READ_LOGS" /> + <!-- 鏋佸厜鎺ㄩ�佺粨鏉� --> + <application android:allowBackup="true" android:icon="@drawable/Icon" android:networkSecurityConfig="@xml/network_security_config" android:largeHeap="true" android:label="ON+"> + <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.hdl.onpro.fileProvider" android:grantUriPermissions="true" android:exported="false"> + <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> + </provider> + <!--鏋佸厜鎺ㄩ��--> + <!-- Required SDK 鏍稿績鍔熻兘--> + <!-- 鍙厤缃� android:process 鍙傛暟灏� PushService 鏀惧湪鍏朵粬杩涚▼涓� --> + <service android:name="cn.jpush.android.service.PushService" android:enabled="true" android:exported="false"> + <intent-filter> + <action android:name="cn.jpush.android.intent.REGISTER" /> + <action android:name="cn.jpush.android.intent.REPORT" /> + <action android:name="cn.jpush.android.intent.PushService" /> + <action android:name="cn.jpush.android.intent.PUSH_TIME" /> + </intent-filter> + </service> + <!-- since 3.0.9 Required SDK 鏍稿績鍔熻兘--> + <provider android:authorities="com.hdl.onpro.DataProvider" android:name="cn.jpush.android.service.DataProvider" android:exported="true" /> + <!-- since 1.8.0 option 鍙�夐」銆傜敤浜庡悓涓�璁惧涓笉鍚屽簲鐢ㄧ殑 JPush 鏈嶅姟鐩镐簰鎷夎捣鐨勫姛鑳姐�� --> + <!-- 鑻ヤ笉鍚敤璇ュ姛鑳藉彲鍒犻櫎璇ョ粍浠讹紝鎴栨妸 enabled 璁剧疆鎴� false 锛汚pp 涓嶄細琚叾浠� App 鎷夎捣锛屼絾浼氭媺璧峰叾浠栫殑 App銆� --> + <service android:name="cn.jpush.android.service.DaemonService" android:enabled="false" android:exported="true"> + <intent-filter> + <action android:name="cn.jpush.android.intent.DaemonService" /> + <category android:name="com.hdl.onpro" /> + </intent-filter> + </service> + <!-- since 3.1.0 Required SDK 鏍稿績鍔熻兘--> + <provider android:authorities="com.hdl.onpro.DownloadProvider" android:name="cn.jpush.android.service.DownloadProvider" android:exported="true" /> + <!-- Required SDK 鏍稿績鍔熻兘--> + <receiver android:name="cn.jpush.android.service.PushReceiver" android:enabled="true"> + <intent-filter android:priority="1000"> + <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> + <category android:name="com.hdl.onpro" /> + </intent-filter> + <intent-filter> + <action android:name="android.intent.action.USER_PRESENT" /> + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> + </intent-filter> + <!-- Optional --> + <intent-filter> + <action android:name="android.intent.action.PACKAGE_ADDED" /> + <action android:name="android.intent.action.PACKAGE_REMOVED" /> + <data android:scheme="package" /> + </intent-filter> + </receiver> + <!-- Required SDK 鏍稿績鍔熻兘--> + <!-- 鑻ユ偍鐨勪笟鍔′腑鏈変娇鐢ㄦ瀬鍏夊瘜濯掍綋鍔熻兘锛屾垨鑰呮瀬鍏夋棭涓婂ソ鍔熻兘锛岄渶瑕佹妸姝� Activity 鐨� exported 璁剧疆鎴� true銆� --> + <activity android:name="cn.jpush.android.ui.PushActivity" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar" android:exported="false"> + <intent-filter> + <action android:name="cn.jpush.android.ui.PushActivity" /> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="com.hdl.onpro" /> + </intent-filter> + </activity> + <!-- SDK 鏍稿績鍔熻兘--> + <!-- 鑻ユ偍鐨勪笟鍔′腑鏈変娇鐢ㄦ瀬鍏夊瘜濯掍綋鍔熻兘锛屾垨鑰呮瀬鍏夋棭涓婂ソ鍔熻兘锛岄渶瑕佹妸姝� Activity 鐨� exported 璁剧疆鎴� true銆� --> + <activity android:name="cn.jpush.android.ui.PopWinActivity" android:configChanges="orientation|keyboardHidden" android:exported="false" android:theme="@style/MyDialogStyle"> + <intent-filter> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="com.hdl.onpro" /> + </intent-filter> + </activity> + <!-- since 3.6.0 --> + <activity android:name="cn.jpush.android.service.DActivity" android:enabled="true" android:exported="true" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:taskAffinity="jpush.custom"> + <intent-filter> + <action android:name="cn.jpush.android.intent.DActivity" /> + <category android:name="com.hdl.onpro" /> + </intent-filter> + </activity> + <!-- Required SDK 鏍稿績鍔熻兘--> + <receiver android:name="cn.jpush.android.service.AlarmReceiver" /> + <!-- 3.5.0鏂板锛岀敤浜庡畾鏃跺睍绀哄姛鑳� --> + <receiver android:name="cn.jpush.android.service.SchedulerReceiver" android:exported="false" /> + <!--Required SDK鏍稿績鍔熻兘 since 3.3.0--> + <activity android:name="cn.jpush.android.service.JNotifyActivity" android:exported="true" android:taskAffinity="jpush.custom" android:theme="@android:style/Theme.Translucent.NoTitleBar"> + <intent-filter> + <action android:name="cn.jpush.android.intent.JNotifyActivity" /> + <category android:name="com.hdl.onpro" /> + </intent-filter> + </activity> + <!-- Required. For publish channel feature --> + <!-- JPUSH_CHANNEL 鏄负浜嗘柟渚垮紑鍙戣�呯粺璁� APK 鍒嗗彂娓犻亾銆�--> + <!-- 渚嬪: --> + <!-- 鍙戝埌 Google Play 鐨� APK 鍙互璁剧疆涓� google-play; --> + <!-- 鍙戝埌鍏朵粬甯傚満鐨� APK 鍙互璁剧疆涓� xxx-market銆� --> + <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" /> + <!-- Required. AppKey copied from Portal --> + <meta-data android:name="JPUSH_APPKEY" android:value="cbd90743ac45cbca06c8118b" /> + <!-- 鏋佸厜鎺ㄩ�佺粨鏉� --> + </application> +</manifest> \ No newline at end of file diff --git "a/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/JPush/JPushReceiver.cs" "b/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/JPush/JPushReceiver.cs" new file mode 100644 index 0000000..ccc38c0 --- /dev/null +++ "b/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/JPush/JPushReceiver.cs" @@ -0,0 +1,208 @@ +锘� +using System; +using Android.Content; +using CN.Jpush.Android.Api; +using CN.Jpush.Android.Service; +using HDL_ON; +using HDL_ON.DAL.Server; +using Shared; + +namespace HDL_ON_Android +{ + + [BroadcastReceiver(Enabled = true, Exported = false)] + [Android.App.IntentFilter(new string[] + { + "cn.jpush.android.intent.RECEIVE_MESSAGE" + }, + Categories=new string[] + { + "com.hdl.onpro" + })] + public class JPushReceiver : JPushMessageReceiver + { + + private static string TAG = "JPushReceiver"; + /// <summary> + /// 鐢ㄦ埛鐐瑰嚮鎵撳紑浜嗛�氱煡 + /// 鐐瑰嚮閫氱煡鍥炶皟 + /// </summary> + /// <param name="context"></param> + /// <param name="notificationMessage"></param> + public override void OnNotifyMessageOpened(Context context, NotificationMessage notificationMessage) + { + //2020-12-23 瑙e喅鐐瑰嚮閫氱煡鏍忔墦寮�涓嶄簡APP闂 + //base.OnNotifyMessageOpened(context, notificationMessage); + + OpenNotification(context, notificationMessage); + } + + /// <summary> + /// 鏀跺埌閫氱煡鍥炶皟 + /// </summary> + /// <param name="p0"></param> + /// <param name="p1"></param> + public override void OnNotifyMessageArrived(Context context, NotificationMessage notificationMessage) + { + base.OnNotifyMessageArrived(context, notificationMessage); + + var pushMes = new JPushMessageInfo() + { + Title = notificationMessage.NotificationTitle, + Content = notificationMessage.NotificationContent, + Extras = notificationMessage.NotificationExtras + }; + + var jpushExpandData = GetJPushExpandData(pushMes); + if (jpushExpandData != null && jpushExpandData.messageType != null) + { + pushMes.messageType = jpushExpandData.messageType; + pushMes.expantContent = jpushExpandData.expantContent; + Utlis.WriteLine("PushMes messageType : " + pushMes.messageType); + } + + Utlis.WriteLine("PushMes title : " + pushMes.Title); + Utlis.WriteLine("PushMes message : " + pushMes.Content); + Utlis.WriteLine("PushMes extras : " + pushMes.Extras); + Shared.Application.RunOnMainThread(() => + { + HDLCommon.Current.AdjustPushMessage(pushMes); + }); + } + + /// <summary> + /// + /// </summary> + /// <param name="pushMes"></param> + /// <returns></returns> + ExpandData GetJPushExpandData(JPushMessageInfo pushMes) + { + try + { + if (pushMes.Extras != null) + { + var jpushExpandData = Newtonsoft.Json.JsonConvert.DeserializeObject<JPushExpandData>(pushMes.Extras.ToString()); + return Newtonsoft.Json.JsonConvert.DeserializeObject<ExpandData>(jpushExpandData.expandData); + } + return null; + } + catch + { + return null; + } + } + + + /// <summary> + /// 娉ㄥ唽鎴愬姛鍥炶皟 + /// </summary> + /// <param name="p0"></param> + /// <param name="p1"></param> + public override void OnRegister(Context context, string p1) + { + base.OnRegister(context, p1); + Utlis.WriteLine("JPushOnRegister: " + p1); + } + + ///// <summary> + ///// 澶勭悊鏋佸厜淇℃伅鎺ㄩ�� + ///// </summary> + ///// <param name="title">鏍囬</param> + ///// <param name="message">淇℃伅</param> + ///// <param name="extras">璐熻浇鏁版嵁</param> + //public void AdjustJiguangMsgPush(JPushMessageInfo JPushMessageInfo) + //{ + // try + // { + // if (JPushMessageInfo.Extras.Contains("Offline") == true) + // { + // Shared.Application.RunOnMainThread(() => + // { + // //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈� + // new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.LoggedOnOtherDevices), Language.StringByID(StringId.Close)).Show(); + // //2020-12-04 寰呭鍔犻��鍑虹櫥褰曟搷浣� + // }); + // return; + // } + // else + // { + // Shared.Application.RunOnMainThread(() => + // { + // new Alert(JPushMessageInfo.Title, JPushMessageInfo.Content, Language.StringByID(StringId.Close)).Show(); + // }); + // return; + + // } + // } + // catch + // { + + // } + //} + + /// <summary> + /// 鎵撳紑娑堟伅鏄剧ず鐣岄潰.010000 + /// </summary> + /// <param name="context"></param> + /// <param name="notificationMessage"></param> + private void OpenNotification(Context context, NotificationMessage notificationMessage) + { + try + { + var pushMes = new JPushMessageInfo() + { + Title = notificationMessage.NotificationTitle, + Content = notificationMessage.NotificationContent, + Extras = notificationMessage.NotificationExtras + }; + + var jpushExpandData = GetJPushExpandData(pushMes); + if (jpushExpandData != null && jpushExpandData.messageType != null) + { + pushMes.messageType = jpushExpandData.messageType; + pushMes.expantContent = jpushExpandData.expantContent; + Utlis.WriteLine("PushMes messageType : " + pushMes.messageType); + } + + Utlis.WriteLine("PushMes title : " + pushMes.Title); + Utlis.WriteLine("PushMes message : " + pushMes.Content); + Utlis.WriteLine("PushMes extras : " + pushMes.Extras); + Shared.Application.RunOnMainThread(() => + { + Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class); + i.SetFlags(ActivityFlags.NewTask); + context.StartActivity(i); + + HDLCommon.Current.AdjustPushMessage(pushMes); + }); + + //Shared.Application.RunOnMainThread(() => + //{ + // if (Shared.Application.Activity == null) + // { + // var tempIntent = new Intent(context, typeof(Shared.BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class); + // tempIntent.SetFlags(ActivityFlags.BroughtToFront); + // context.StartActivity(tempIntent); + + // HDLCommon.Current.AdjustPushMessage(pushMes); + // } + // else + // { + + // (Shared.Application.Activity as BaseActivity).MoveToFront(); + // HDLCommon.Current.AdjustPushMessage(pushMes); + // } + //}); + } + catch + { + + } + //catch (Exception ex) + //{ + // Utlis.WriteLine(ex.ToString()); + //} + } + } + +} \ No newline at end of file diff --git "a/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/JPush/JPushService.cs" "b/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/JPush/JPushService.cs" new file mode 100644 index 0000000..06ef6c5 --- /dev/null +++ "b/Xamarin.Android\351\233\206\346\210\220\345\217\202\350\200\203/JPush/JPushService.cs" @@ -0,0 +1,11 @@ +锘� +using CN.Jpush.Android.Service; + +namespace HDL_ON_Android +{ + [Android.App.Service(Enabled =true,Exported =false,Process = ":pushcore")] + [Android.App.IntentFilter(new string[] { "cn.jiguang.user.service.action" })] + public class JPushService: JCommonService + { + } +} \ No newline at end of file -- Gitblit v1.8.0