推送通知是不工作的设备 [英] push notification is not working on device

查看:195
本文介绍了推送通知是不工作的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想在我的应用程序创建推送通知我得到我已书面设备令牌和PHP脚本看到一些教程,但现在我没有得到我的设备推送通知不能做不是我已经做了错在这里请帮我..

Hi I’m trying to create push notification in my app I’m getting device token and php script I have written by see some tutorials but now I’m not getting the push notification in my device not don’t where I have done wrong here please help me out..

这是我的PHP脚本...

this is my php script ...

<?php

   if($_POST['message']){

   $deviceToken ='here i have given my device token ';

   $message = stripcslashes($_POST['message']);

    $payload = '{
         "aps" :
      {
      "alert" :"'.$message.'",
      "badge" : 1,
      "sound" : "bingbong.aiff"
     }  
    }';
    $ctx = stream_context_create();
    stream_context_set_option($ctx,'ssl', 'local_cert','ck.pem');
    stream_context_set_option($ctx,'ssl','passphrase', 'bali');
    $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195',$err,$errstr,60,STREAM_CLIENT_CONNECT,$ctx);
   if(!fp){
       print "Failed to connect $err $errstrn";
       return;
       }else{
            print "notifications sent!";
           }
             $devArray = array();
             $devArray[] = $deviceToken;

             foreach($devArray as $deviceToken){
$msg = chr(0) . pack("n",32) . pack("H", str_replace(' ',' ',$deviceToken)).pack("n",strlen($payload)) . $payload;
        print "sending message:" .$payload . "n";
        fwrite($fp,$msg);
       }
           fclose($fp);
       }

      ?>

我又写道使用本教程 rel=\"nofollow\">这个剧本

i worte this script using this tutorial here

本PHP脚本我尝试我的本地主机上运行,​​但不工作请告诉IM的地方在脚本中做错了

using this php script im trying to run on my local host but not working pls tell where im doing wrong in the script

感谢。

推荐答案

大家好我想通了,在这里我错了

hi guys i figured out where i was wrong

pack("H*", str_replace(' ',' ',$deviceToken)).

在我约code星号是把星号的工作对我罚款后失踪近^ h

in my about code the asterisk symbol was missing near h after putting asterisk its working fine for me

感谢乌拉圭回合的重赛

这篇关于推送通知是不工作的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆