ここで発生する可能性のあることの1つは、次のとおりです。
- あなたのコードは実際にsendPushを呼び出す前にメッセージを処理して送信しようとしていますが、これが問題の一部を引き起こしている可能性があります。
- APIキーにサインアップして、コード内のその部分を置き換えましたか?
- デモクライアントアプリケーションでは、登録を実際に活用する方法を示しています。次のGitHubの問題に関する私のコメントを参照してください:https ://github.com/mwillbanks/Zend_Mobile/issues/16
- サーバーには、デバイスからの登録IDが必要です。これはおそらくあなたが持っていないものです。
- 登録IDを取得する1つの方法は、クライアントアプリ内のonRegistered呼び出しで、Log.i( "MY_APP_TAG"、regId);を実行することです。次に、logcatの出力を確認します。
Androidの例
public class GCMIntentService extends GCMBaseIntentService {
public GCMIntentService() {
super(Constants.SENDER_ID);
}
@Override
protected void onRegistered(Context context, String regId) {
Log.i("MY_APP_TAG", "Registered: " + regId);
}
@Override
protected void onUnregistered(Context context, String regId) {
// write a call here to send the regId to your server and unregister it
}
@Override
protected void onMessage(Context context, Intent intent) {
Log.i("MY_APP_TAG", "Received message!");
// grabbing data looks like the following; the assumption
// is title is part of the data string.
String title = intent.getExtras().getString("title");
}
}
*Zend_Mobile_Push_Gcmの例*
貼り付けたコードを提供した更新されたリンク(http://pastebin.com/NhrD5N6i)を参照してください。上記のテキストボックスで登録IDを使用することをお勧めします。