首页新闻找找看学习计划

ios推送 错误8 : Invalid token怎么解决

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-12-24 14:36

用c#写的ios消息推送,引用PushSharp.Apple和PushSharp.Core 运行时出现下面错误:
 APNS NotificationFailureException -> 8 : Invalid token 

网上有说是token 64个字节的问题,http://www.cocoachina.com/bbs/read.php?tid=165961 不知道要怎么转成32个字节?

还有.ForDeviceToken(tokenID)方法吧token改成32个字节 提示错误 5 : Invalid token size  
求高手指点一下 

 private void Form1_Load(object sender, EventArgs e)
        {  
            string token =  "8d6c30144e7a93e73cc1fafb0a5000000001a0a0bd1f66c9e0ab857291d00000"; 
           StarServices("production_identity.p12", "123123");
           SendSingleMess(token, "这是通过APNS的推送消息");
         }
 public void StarServices(string keyPath, string keyWord)
        {
            try
            {
                      push.OnNotificationSent += NotificationSent;    
            push.OnNotificationFailed += NotificationFailed; 
            push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;  
            push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;    
            push.OnChannelException += ChannelException;    
            push.OnServiceException += ServiceException;   
            push.OnChannelCreated += ChannelCreated;  //
            push.OnChannelDestroyed += ChannelDestroyed;  //
                var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, keyPath));
                push.RegisterAppleService(new ApplePushChannelSettings(appleCert, keyWord));  
            }
            catch { }
        }
 public void StopServices()
        {
            try
            {
                push.StopAllServices();
            }
            catch { }
        }
        public void SendSingleMess(string tokenID, string  message)
        {
            try
            { 
                push.QueueNotification(new AppleNotification()
                                           .ForDeviceToken(tokenID)
                                           .WithAlert(message)
                                           .WithBadge(7)
                                           .WithSound("sound.caf"));  
                Console.ReadLine();    
            }
            catch  (Exception e)
            {
                Console.WriteLine("error:" + e.Message);
            }
        }
         
        static void DeviceSubscriptionChanged(object sender, string oldSubscriptionId, string newSubscriptionId, INotification notification)
        {
            //Currently this event will only ever happen for Android GCM
            Console.WriteLine("Device Registration Changed:  Old-> " + oldSubscriptionId + "  New-> " + newSubscriptionId + " -> " + notification);
        }

        static void NotificationSent(object sender, INotification notification)
        { 
            Console.WriteLine("Sent: " + sender + " -> " + notification);
        }

   ……
Ciara的主页 Ciara | 菜鸟二级 | 园豆:202
提问于:2014-12-23 10:14
< >
分享
所有回答(1)
0

楼主问题最后解决没?怎么解决的??

当时我就吓傻啦 | 园豆:207 (菜鸟二级) | 2015-12-09 18:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册