2016-05-05 34 views
2

我已经创建了一个生产版本.p12文件,将通知发送到iPhone并使用testflight安装了应用程序。问题与PushSharp苹果通知从版本4.0.10.0到Testflight

从我的示例控制台应用程序发送通知时,我总是收到通知发送回调,但没有通知到达设备。

我Pushsharp版本4.0.10.0 和发送通知的代码看起来是这样的:

public static void SendAppleNotification() 
    { 
     // Configuration (NOTE: .pfx can also be used here) 
     var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, "C:\\Users\\MancMiniUser\\Documents\\visual studio 2013\\Projects\\PushSharpDemo\\PushSharpDemo\\Resources\\P12CertifyPIE.p12", "1234"); 

     // Create a new broker 
     var apnsBroker = new ApnsServiceBroker(config); 

     // Wire up events 
     apnsBroker.OnNotificationFailed += (notification, aggregateEx) => 
     { 

      aggregateEx.Handle(ex => 
      { 

       // See what kind of exception it was to further diagnose 
       if (ex is ApnsNotificationException) 
       { 
        var notificationException = (ApnsNotificationException)ex; 

        // Deal with the failed notification 
        var apnsNotification = notificationException.Notification; 
        var statusCode = notificationException.ErrorStatusCode; 

        Console.WriteLine("Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}"); 

       } 
       else 
       { 
        // Inner exception might hold more useful information like an ApnsConnectionException   
        Console.WriteLine("Apple Notification Failed for some unknown reason : {ex.InnerException}"); 
       } 

       // Mark it as handled 
       return true; 
      }); 
     }; 

     apnsBroker.OnNotificationSucceeded += (notification) => 
     { 
      Console.WriteLine("Apple Notification Sent!"); 
     }; 

     // Start the broker 
     apnsBroker.Start(); 


     // Queue a notification to send 
     apnsBroker.QueueNotification(new ApnsNotification 
     { 
      DeviceToken = "3cfcc2ceefe6675d89b063e2e39d03503b3917250e6743d185c755e9e2c3579d", 
      Payload = JObject.Parse("{\"aps\":{\"alert\":\"Hello from sourabh v.4.0 Tester.\",\"badge\":\"1\"}}") 

     }); 

     // Stop the broker, wait for it to finish 
     // This isn't done after every message, but after you're 
     // done with the broker 
     apnsBroker.Stop(); 
    } 

谁能帮我这个,为什么即使通知发送回调来未接到通知?

回答

2

您创建生产证书,那么你作为 ApnsConfiguration.ApnsServerEnvironment.Production

  • 无功配置=新ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production,“C使用方法:\用户\ MancMiniUser \文档\的Visual Studio 2013 \ Projects \ PushSharpDemo \ PushSharpDemo \ Resources \ P12CertifyPIE.p12“,”1234“);