gcm推送通知:第一次成功,然后未在IOS中注册 [英] gcm push notification: first success, then not registered in IOS

查看:117
本文介绍了gcm推送通知:第一次成功,然后未在IOS中注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在所有通过IOS云端消息接收通知之后,我有这个问题:
i在php中发送关于服务器密钥和设备令牌的通知,第一次响应是成功但是在设备上,第二次以及随后的时间内没有收到任何内容,响应是notRegistered。我重复了所有的章节:在钥匙串中创建新密钥,加载配置文件,下载.cer,安装在钥匙串中,导出.p12并在Google平台上为GoogleService-Info.plist插入证书,并在php中重新加载设备的regId ,但答复总是这样。



这是我的php:

  $ apiKey =服务器密钥; 
$ regId ='注册令牌';
$ url ='https://gcm-http.googleapis.com/gcm/send';
$ post ='{到:'。$ regId。',content_available:true,priority:high,notification:{title:test身体:测试}}';

$ headers = array(
Authorization:key = $ apiKey,
'Content-Type:application / json'
);

$ ch = curl_init();

curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_POST,true);
curl_setopt($ ch,CURLOPT_HTTPHEADER,$ headers);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ ch,CURLOPT_POSTFIELDS,$ post);
curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false);

$ result = curl_exec($ ch);
if(curl_errno($ ch))
{
echo'GCM error:'。 curl_error($ ch);
}
curl_close($ ch);
echo $ result;


解决方案

/ p>

问题在于没有新配置文件的旧帐户,请转到:XCode帐户 - > Apple ID并查看详细信息 - >全部下载。确保转到:目标 - >项目名称 - >生成设置 - >搜索预配配置文件 - >自动更改并选择您的预配置配置文件用于证书。神秘的是xcode的原因不警告我没有找到正确的Provisioning Profile(不同的bundle id)。


After all passages for receive the notification with google cloud messaging in IOS but i have this problem: i send the post in php for the notification with server key and device's token, at first time the response is "success" but not receive nothing on device, at the second time, and subsequent times, the response is "notRegistered". I repeat all passages: create new key in keychain, load in provisioning profile, download the .cer, install in keychain, export .p12 and insert the certificates on google platform for "GoogleService-Info.plist" and reload the device's regId at php, but the response is always this. Help me please.

This is my php :

    $apiKey = "server key";
    $regId = 'registration token';
    $url = 'https://gcm-http.googleapis.com/gcm/send';
    $post = '{"to" : "' . $regId . '", "content_available" : true, "priority" : "high", "notification":  {"title" : "test", "body" : "test"}}';

    $headers = array(
            "Authorization:key=$apiKey",
            'Content-Type:application/json'
            );

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);
if ( curl_errno( $ch ) )
{
    echo 'GCM error: ' . curl_error( $ch );
}
curl_close( $ch );
    echo $result;

解决方案

Op's own answer, removed from the edited question:

The problem was the old account without the new provisioning profile, go to : XCode Accounts -> Apple IDs and view details -> Download All. For be sure go to : Targets -> project name -> Build Settings -> search "Provisioning Profile" -> change automatic and select your provisioning profile in use for certificates. The mystery is the xcode's reason don't warning me don't find the correct Provisioning Profile (different bundle id).

这篇关于gcm推送通知:第一次成功,然后未在IOS中注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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