Iphone 苹果推送通知doen';触不到
我准备了一个iphone应用程序来获取推送通知消息。我可以使用2195端口、gateway.sandbox.push.apple.com和本地p12文件发送推送消息 我在appstore中的应用程序,现在我正在使用gateway.push.apple.com和分发p12文件,但消息无法到达真实的应用程序(在appstore中) 设备id在本地和产品版本中是不同的,我知道这一点,所以我尝试从.net发送新的设备id 同样的代码在本地工作,我可以发送消息,但当我将推送消息发送到实际应用程序时,没有使用相同代码的消息到达iphone。我在这段时间内没有错误 我能做什么 我的c代码如下所示。我怎样才能解决我的问题?没有错误,但消息无法到达具有分发证书的设备Iphone 苹果推送通知doen';触不到,iphone,xcode,push-notification,app-store,Iphone,Xcode,Push Notification,App Store,我准备了一个iphone应用程序来获取推送通知消息。我可以使用2195端口、gateway.sandbox.push.apple.com和本地p12文件发送推送消息 我在appstore中的应用程序,现在我正在使用gateway.push.apple.com和分发p12文件,但消息无法到达真实的应用程序(在appstore中) 设备id在本地和产品版本中是不同的,我知道这一点,所以我尝试从.net发送新的设备id 同样的代码在本地工作,我可以发送消息,但当我将推送消息发送到实际应用程序时,没有使
int port = 2195;
String hostname = "gateway.push.apple.com";
String certificatePath = HttpContext.Current.Server.MapPath("distribution.p12");
X509Certificate2 clientCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "xxx", X509KeyStorageFlags.MachineKeySet |
X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate);
TcpClient client = new TcpClient(hostname, port);
SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
try
{
sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, true);
}
catch (Exception e)
{
throw (e);
client.Close();
return;
}
MemoryStream memoryStream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(memoryStream);
writer.Write((byte)0);
writer.Write((byte)0); //The first byte of the deviceId length (big-endian first byte)
writer.Write((byte)32); //The deviceId length (big-endian second byte)
//String deviceID = "f1430c99 910d292d 2f756294 f2f6b348 153bc215 d5404447 16b294eb fdb9496c";
writer.Write(HexStringToByteArray(deviceID.ToUpper()));
String payload = "{\"aps\":{\"alert\":\"" + Mesaj + "\",\"badge\":0,\"sound\":\"default\"}}";
writer.Write((byte)0);
writer.Write((byte)payload.Length);
byte[] b1 = System.Text.Encoding.UTF8.GetBytes(payload);
writer.Write(b1);
writer.Flush();
byte[] array = memoryStream.ToArray();
sslStream.Write(array);
sslStream.Flush();
client.Close();
在配置文件appid中启用推送通知后 然后,只有您才能从正在运行的设备获取设备令牌。根据设备令牌,您可以发送通知 开发过程:gateway.sandbox.push.apple.com端口2195 分发过程:gateway.push.apple.com端口2195 请参阅以下链接:
推送通知启用开发者和发行版我使用了运行设备的新设备id我使用了gateway.Push.apple.com端口2195我可以使用开发者证书发送通知,但无法从appstore向下载的应用程序发送消息我在.net中没有错误我仍然有问题您必须使用设备令牌发送通知。要获取设备令牌-(void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{}我使用了设备令牌,我获取了与上面相同代码的设备令牌。这对我来说非常重要,请帮助我:(启用通知流程后。您必须将应用程序重新上载到itunes应用商店。在生成之前,请将.pem文件包含到项目文件夹中。我的项目不包含pem文件,我的问题是否与pem文件有关?我应该将此文件添加到哪个文件夹?我的问题仍然存在?您无法使用您的开发人员设备进行测试?如果通知正确获取意味着您可以在itunes应用商店中更新应用程序。