11

APNS 経由で iPhone アプリにプッシュ通知メッセージを送信するには、Delphi でプロバイダー サーバーを構築する必要があります。

これは、Indy コンポーネントを介して実行できることを読みました。また、Apple が提供する SSL 証明書 (.p12) をインストールする必要があります。

Delphiでこれを始めるための指針を探しています。使用するのに適したライブラリは何ですか?このようなことを行うサンプルコードを知っている人はいますか?

Ruby & PHPC#およびJAVAのサンプルを次に示します。

4

2 に答える 2

5

OK私はこれを次のように管理しました:
インディTidTCPClientTIdSSLIOHandlerSocketフォームを追加してリンクします。TIdSSLIOHandlerSocket、set CertFile、およびKeyFile適切な.pemファイルでSSLオプションを設定します。メソッドをにsslvSSLv23、モードをに設定しますsslmClient
のイベントで、キーのパスワードを設定しますIOHandlerOnGetPassword

便利なURL: http ://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html http://www.raywenderlich.com/3443/apple-push-notification-services -tutorial-part-12

コーディングの面では:

Nb HexDataは、iPhoneアプリから送信されたIDです。

function SendNotification(HexData: String; Count: Integer): Boolean;
  var
    p_DataSize,
    I: Integer;
    p_payllen: Byte;
    p_json   : String;
    p_sndmsg : String;
  begin
// Delphi 6 so needed to create JSON by hand<br>
    p_json := '{"aps":{';
    if (Count > 0) then
    begin
      p_json := p_json + '"alert":"You Have ' + IntToStr(Count);
      if (count = 1) then
        p_json := p_json + ' Reminder'
      else<br>
        p_json := p_json + ' Reminders';
      p_json := p_json + '","sound": "default",';
    end;
    p_json := p_json + '"badge":' + inttostr(Count) + '}}';
    p_payllen := length(p_json);
    // Hard code the first part of message as it never changes
    p_sndmsg :=  chr(0) + chr(0) + chr(32);
    // Convert hex string to binary data 
    p_DataSize := Length(HexData) div 2;
    for I := 0 to p_DataSize-1 do
      p_sndmsg := p_sndmsg + char(Byte(StrToInt('$' + Copy(HexData, (I*2)+1,
        2))));
    //Now need to add length of json string and string itself
    p_sndmsg := p_sndmsg + chr(0) + Char(p_payllen) + p_json;
    try
    // According to Apple can't connect/disconnect for each message so leave open for later
      if (not PushClient.Connected) then
        PushClient.Connect;
      PushClient.IOHandler.Send(p_sndmsg[1], length(p_sndmsg));
    except
      on e : exception do
        Log_Error(e.message);
    end;
  end;
于 2012-08-07T14:52:35.907 に答える
2

Rogierが言ったように、Java/phpまたはrubyコードを移植してみることができます。彼のhttp://www.pushwoosh.com/をhttp://urbanairship.com/に似たものを見てください。

于 2012-07-11T06:00:48.673 に答える