-
Notifications
You must be signed in to change notification settings - Fork 1.5k
The Apple Push Notification service (APNs) will no longer support the legacy binary protocol as of November 2020. #923
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
Comments
This is something I also would like to know. If anyone could shed some light on this it would be greatly appreciated. |
Hello, |
The commit 96ff502 says "Add basic Http2 support for APNS", but in some articles found that PushSharp doesn't support Http2 API. It will be really helpful if someone can clear out this confusion. Thanks |
I also saw this and @Redth covered previously (here: #880) that http/2 support requires a bunch of changes/etc. and isn't coming to PushSharp.
|
Thanks @cvocvo I went for the azure option, so this is going to make my life so much easier in the long run. Azure offers the capability of managing devices through their hub, or just use it as a pass through service and you manage your own devices...which fits perfectly into my use case. |
Apple changed deadline. And also you can do a little trick by adding ApnsHttp2Connection and other files in project, they are already in source code of PushSharp, you need to make your own PushSharp.Apple.dll
|
you can use dotAPNS library to push notifications using HTTP/2 |
I am using PushSharp .NetCore and worried about this deadline as the current structure is working perfectly fine for me. Any updates? |
This solution worked well for me. Thank you. |
Will PushSharp be updated to support HTTP/2-based Apple Push Notification? |
Yes I hope there will be a quick update for this HTTP/2 issue soon. |
It is easy to send Apple Push Notification. You don't need any GitHub libraries or Nuget packages. I use this simple function. It only depends on API from .Net Core 3.0. static async Task Send(string text, string deviceToken)
{
var cert = new X509Certificate2("certificate.p12", "password", X509KeyStorageFlags.MachineKeySet);
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.push.apple.com/3/device/" + deviceToken);
req.Version = new Version(2, 0);
req.Headers.Add("apns-topic", cert.Subject.Substring(cert.Subject.LastIndexOf('=') + 1));
req.Content = new StringContent("{\"aps\":{\"alert\":\"" + HttpUtility.JavaScriptStringEncode(text) + "\"}}");
var handler = new HttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual };
handler.ClientCertificates.Add(cert);
var response = await new HttpClient(handler).SendAsync(req);
string content = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) throw new Exception("APNS error " + response.StatusCode + ": " + content);
} |
I created a .NET Core 3.1 library with the code above. Then I refer to the library from a .NET Framework 4.7.2 project. The problem is that I get this error: Error CS1705 Assembly 'X' with identity 'X, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' In NuGet Manager for both projects, I have tried to add System.Runtime 4.3.1. Still I get the same error. How can this be fixed? |
You can't mix .NET Core and .NET Famework together within the same project. You should convert all your .NET Framework 4.7.2 project to .NET 5. If it is too much difficult for you, it's also possible to compile |
Hi, anyone here with a working solution for Apple push using HTTP/2? |
This is my solution: PushSharp 4.0.10.0: HTTP/2-based Apple Push Notification service (APNs) I removed the iOS structure of PushSharp and implemented dotAPNS. I am still using PushSharp for Google. |
Thank you @hussoftware, yes dotAPNS is perfect for core. |
@ellenkuipers I built a quick helper class for myself within a day and pointed the existing PushSharp calls to this helper. You can use and improve the helper class I shared in stackoverflow or can write a better one from scratch. dotAPNS does pretty much majority of the push notifications work. |
Hi can you please share some piece of code for NET Core 3.0.. As we are getting error related to SSL after uploading it on server |
@21pg Have you checked the following url? I added a sample there: |
Hi @21pg , I followed all instructions under "dotAPNS ASP.NET Core integration", see https://github.com/alexalok/dotAPNS SendPushAsync: Also we had to change the HTTP version to "2.0" in the configuration settings in Azure. In protocol settings we have HTTPS Only = On and Minimum TLS Version = 1.2. Hope this will help. Good luck! |
Thanks for your reply I tried this but |
Has anyone had any issues with a certificate that works for Production but not Development? I've generated my wallet pass certificate from apple - the one you use to create apple passes. When I send the HTTP/2 request to the production server - everything works. The moment I send it to the development one though, I get I think the issue might be with the certificate - if it was somehow created only for a production environment. |
Hi I am getting " MissingProviderToken" error. string certificatePath = HttpContext.Current.Server.MapPath("certficate.p12"); |
Hi,
I have been using this library for 2 years. Apple says that "we recommend updating to the HTTP/2-based APNs provider API as soon as possible."
Will we be able to continue sending notifications with this library?
News link : https://developer.apple.com/news/?id=11042019a
The text was updated successfully, but these errors were encountered: