alexalok / dotAPNS

dotAPNS is a library used to send push notifications to Apple devices using Apple Push Notification service via HTTP/2 API.
Apache License 2.0
114 stars 34 forks source link

Messages can be pushed locally when running, but cannot be pushed successfully after being deployed to the server #95

Closed FelixSun closed 2 years ago

FelixSun commented 3 years ago

I don’t know where the problem is. I used pushsharp+p12 certificate to push before. I recently wanted to change to p8 certificate for push. I quoted dotapns. The local test is running well, and the push message is all normal. After deploying to the server, it cannot be pushed. News, I don’t know what went wrong, have you encountered similar problems? Hope to get your help, thank you very much!

alexalok commented 3 years ago

Are you using Azure by any chance?

Ashita-Designscape commented 2 years ago

I am also facing the same issue, works fine locally, but when deployed on server notifications are not working. I am using azure server.

alexalok commented 2 years ago

I am using azure server.

Please see https://stackoverflow.com/a/68913081 for a possible solution.

YagneshKhamar commented 2 years ago

I am also facing same issue on my voip call api, on checking on local system it is working fine, and on deploying the code on server after publishing it, the request doesnt give any answer, on postman I am getting timeout issue after about 5 10 mins. below is the code I am using for my purpose, please help a solution on this....

 var path = "";
            try
            {
                //isProduction = GetConfigurationValue.IsProduction;

                ApplePush applePush = new ApplePush(ApplePushType.Voip);
                applePush.AddAlert("Call");
                applePush.AddBadge(0);
                applePush.AddSound("default");

                applePush.AddCustomProperty("token", token);
                applePush.AddCustomProperty("senderUsername", senderUserName);
                applePush.AddCustomProperty("senderUserImage", senderUserImage);
                applePush.AddCustomProperty("senderFirstname", senderFirstName);
                applePush.AddCustomProperty("isUserVerified", isUserVerified);
                applePush.AddCustomProperty("senderLastname", senderLastName);
                applePush.AddCustomProperty("channelname", channelName);
                applePush.AddCustomProperty("senderId", senderId);
                applePush.AddCustomProperty("isUserLockedByMe", IsUserLockedByMe);

                foreach (var dt in deviceIds)
                {
                    applePush.AddVoipToken(dt);
                }

                path = HttpContext.Current.Server.MapPath(GetConfigurationValue.CertificatePath);

                var options = new ApnsJwtOptions()
                {
                    BundleId = GetConfigurationValue.BundleId,
                    CertFilePath = path,
                    // use either CertContent or CertFilePath, not both
                    KeyId = GetConfigurationValue.APNKeyId,
                    TeamId = GetConfigurationValue.APNTeamId
                };

                var httpClient = new HttpClient(new Http2CustomHandler());
                var apns = ApnsClient.CreateUsingJwt(httpClient, options);                
                if (!isProduction)
                {
                    apns.UseSandbox();
                }

                var result = await apns.SendAsync(applePush);

                return result.IsSuccessful;
            }
            catch (Exception ex)
            {
                throw new Exception(path, ex);
            }
Ashita-Designscape commented 2 years ago

I am using azure server.

Please see https://stackoverflow.com/a/68913081 for a possible solution.

Thank you. this solution worked for azure server. But I am facing problems with plesk.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.