Commit 963257d7 authored by 张盛懿's avatar 张盛懿

Jiguang.JPush

parent da31c5c6
......@@ -86,6 +86,9 @@
<Name>PushPlatform.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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.
......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
using Jiguang.JPush;
using Jiguang.JPush.Model;
using Newtonsoft.Json.Linq;
using PushPlatform.Common.Model;
using PushPlatform.Common.Util;
using System;
using System.Collections.Generic;
using System.Text;
namespace PushInfo.Core.BLL
{
public class JiguangPushMessage
{
private readonly JPushClient _client;
public JiguangPushMessage(string appkey, string masterSecret)
{
_client = new JPushClient(appkey, masterSecret);
}
/// <summary>
/// 发送推送通知
/// 参考文档:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push
/// </summary>
/// <param name="audience">推送目标,支持别名、标签、注册 ID、分群</param>
/// <param name="title">通知标题</param>
/// <param name="alert">通知内容</param>
/// <param name="intent">Android指定跳转页面,如果extras参数不为空,扩展字段将拼接到intent中</param>
/// <param name="extras">扩展字段</param>
/// <param name="isProd">iOS App是否上架,上架之前使用开发证书,上架之后使用生产证书来推送,并且可以将生产证书用于开发环境</param>
/// <returns></returns>
public APIResult<string> SendPush(Audience audience, string title, string alert, string intent, Dictionary<string, object> extras = null, bool isProd = false)
{
APIResult<string> result = new APIResult<string>();
result.Result = 1;
try
{
if (!string.IsNullOrWhiteSpace(intent))
intent = ProcessAndroidIntent(intent, extras);
var pushPayload = new PushPayload
{
Platform = "all", // 所有平台
Audience = audience
};
var notification = new Notification()
{
Android = new Android
{
Alert = alert,
Title = title,
Extras = extras,
Indent = new Dictionary<string, object> { { "url", intent } }
},
IOS = new IOS
{
Alert = new JObject
{
{ "title", title },
{ "body", alert }
},
ContentAvailable = false,
Extras = extras
}
};
pushPayload.Notification = notification;
pushPayload.Options = new Options
{
IsApnsProduction = isProd
};
var response = _client.SendPush(pushPayload);
result.Msg = response.Content;
if (response.StatusCode != System.Net.HttpStatusCode.OK)
result.Result = 0;
}
catch (Exception ex)
{
LogHelper.Error(ex);
result.Result = 0;
result.code = 1;
}
return result;
}
private string ProcessAndroidIntent(string intent, Dictionary<string, object> extras)
{
if (string.IsNullOrWhiteSpace(intent) || extras == null || extras.Count == 0)
return intent;
var param = new StringBuilder();
foreach (var item in extras)
{
var valueType = item.Value.GetType();
if (valueType == typeof(string))
param.AppendFormat("S.{0}=\"{1}\";", item.Key, item.Value);
else if (IsNumericType(item.Value))
param.AppendFormat("i.{0}={1};", item.Key, item.Value);
}
if (param.Length > 0)
return $"{intent.Substring(0, intent.LastIndexOf(";"))};{param}end";
return intent;
}
private bool IsNumericType(object o)
{
switch (Type.GetTypeCode(o.GetType()))
{
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
return true;
default:
return false;
}
}
}
}
......@@ -40,6 +40,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Google.ProtocolBuffers.dll</HintPath>
</Reference>
<Reference Include="Jiguang.JPush, Version=1.2.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Jiguang.JPush.1.2.5\lib\net45\Jiguang.JPush.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Bson">
<HintPath>..\packages\MongoDB.Bson.2.2.4\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
......@@ -56,8 +59,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Quartz">
<HintPath>..\bin\Quartz.dll</HintPath>
......@@ -66,6 +69,7 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -78,6 +82,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BLL\GeTuiPushMessage.cs" />
<Compile Include="BLL\JiguangPushMessage.cs" />
<Compile Include="BLL\MapProjectPushBLL.cs" />
<Compile Include="BLL\MappushUserRoleBLL.cs" />
<Compile Include="BLL\ProcessTaskBLL.cs" />
......@@ -133,7 +138,9 @@
<Name>PushPlatform.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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.
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Jiguang.JPush" version="1.2.5" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -25,6 +25,7 @@
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -77,6 +78,9 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
......@@ -96,9 +100,6 @@
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
</Reference>
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
......
......@@ -51,7 +51,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
......
......@@ -31,7 +31,7 @@
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.6.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="Respond" version="1.2.0" targetFramework="net45" />
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -15,12 +15,13 @@
<AssemblyName>PushPfService</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<WcfConfigValidationEnabled>True</WcfConfigValidationEnabled>
<UseIISExpress>false</UseIISExpress>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -151,7 +152,7 @@
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>63629</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost/PushPfService</IISUrl>
<IISUrl>http://localhost:63629/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
......
......@@ -16,7 +16,7 @@
<RootNamespace>PushPfWebServer</RootNamespace>
<AssemblyName>PushPfWebServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<UseIISExpress>false</UseIISExpress>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
......@@ -24,6 +24,7 @@
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -161,7 +162,7 @@
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>32450</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost/PushPfWebServer</IISUrl>
<IISUrl>http://localhost:32450/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
......
......@@ -17,7 +17,7 @@
<AssemblyName>PushPlatform.Background</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>false</UseIISExpress>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
......@@ -25,6 +25,7 @@
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -77,6 +78,9 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
......@@ -139,11 +143,6 @@
<HintPath>..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
......@@ -688,7 +687,7 @@
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>19013</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost/PushPlatform.Background</IISUrl>
<IISUrl>http://localhost:19013/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
......
......@@ -62,7 +62,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
......
......@@ -25,7 +25,7 @@
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.6.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="Respond" version="1.2.0" targetFramework="net45" />
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -27,6 +27,13 @@ namespace PushTest
{
static void Main(string[] args)
{
var message = new JiguangPushMessage("298ec6f7cdcdee87a3faf64b", "36dd48a9028eeb4471acec46");
message.SendPush(new Jiguang.JPush.Model.Audience { RegistrationId = new List<string> { "1a0018970a578514295" } }, // android: 1a0018970a578514295, ios: 161a3797c8f24d790c1
"上海保供物资管理意见1700", "备用手机号避免因注册1700",
//"intent:#Intent;action=android.intent.action.MAIN;end",
"intent:#Intent;action=android.intent.action.MAIN;component=com.aisha.headache.ui.activity.SplashActivity;S.key1=\"哈哈\";i.key2=2;end",
new Dictionary<string, object> { { "project_id", "9bfc78a8-6d2e-47b9-94cb-c3f40dfd9dc7" } });
var field1 = "<field>501a4360-5648-45be-8aaa-935d5f6673c3</field>"; //体重
var field2 = "<field>c7142c7b-2372-4a79-8626-6ae218e9ae0b</field>"; //身高
using (PushPlatform.Common.NewSmsService.SmsServiceClient sms = new PushPlatform.Common.NewSmsService.SmsServiceClient())
......
......@@ -38,18 +38,21 @@
<Reference Include="Apache.NMS.ActiveMQ">
<HintPath>..\消息队列\Debug\Apache.NMS.ActiveMQ.dll</HintPath>
</Reference>
<Reference Include="Jiguang.JPush, Version=1.2.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Jiguang.JPush.1.2.5\lib\net45\Jiguang.JPush.dll</HintPath>
</Reference>
<Reference Include="MG.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\消息队列\Debug\MG.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -73,6 +76,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\DataSources\PushInfo.Act.Models.QueryResults.PushConfigResult.datasource" />
<None Include="Properties\DataSources\PushInfo.Act.Models.QueryResults.SelectItemDetail.datasource" />
<None Include="Properties\DataSources\PushService.Act.Model.PushMsg1.datasource" />
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Jiguang.JPush" version="1.2.5" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
</packages>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
param($installPath, $toolsPath, $package, $project)
# open json.net splash page on package install
# don't open if json.net is installed as a dependency
try
{
$url = "http://james.newtonking.com/json"
$dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
{
# user is installing from VS NuGet console
# get reference to the window, the console host and the input history
# show webpage if "install-package newtonsoft.json" was last input
$consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
$props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
$prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
if ($prop -eq $null) { return }
$hostInfo = $prop.GetValue($consoleWindow)
if ($hostInfo -eq $null) { return }
$history = $hostInfo.WpfConsole.InputHistory.History
$lastCommand = $history | select -last 1
if ($lastCommand)
{
$lastCommand = $lastCommand.Trim().ToLower()
if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
else
{
# user is installing from VS NuGet dialog
# get reference to the window, then smart output console provider
# show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
$instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
[System.Reflection.BindingFlags]::NonPublic)
$consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($instanceField -eq $null -or $consoleField -eq $null) { return }
$instance = $instanceField.GetValue($null)
if ($instance -eq $null) { return }
$consoleProvider = $consoleField.GetValue($instance)
if ($consoleProvider -eq $null) { return }
$console = $consoleProvider.CreateOutputConsole($false)
$messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($messagesField -eq $null) { return }
$messages = $messagesField.GetValue($console)
if ($messages -eq $null) { return }
$operations = $messages -split "=============================="
$lastOperation = $operations | select -last 1
if ($lastOperation)
{
$lastOperation = $lastOperation.ToLower()
$lines = $lastOperation -split "`r`n"
$installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
if ($installMatch)
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
}
catch
{
# stop potential errors from bubbling up
# worst case the splash page won't open
}
# yolo
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment