【问题标题】:Apple Push Notifications from PL SQL来自 PL SQL 的 Apple 推送通知
【发布时间】:2015-07-24 12:37:16
【问题描述】:

我已阅读此答案: PLSQL APPLE push notifiactions

但我不能使用 Java。 我相信应该有办法从 PL/SQL 联系 APNS,因为我已经使用 PL/SQL 实现了 GCM(Android 通知)。

如何设置证书: 我有一个包含 Apple Push Certificate 和 Private key 的 pem 文件。 我也有委托的根证书。我使用 orapki 将它们添加到钱包中。

我不擅长PL/SQL,所以我的代码可能有问题:

v_url VARCHAR2(200) := 'https://gateway.push.apple.com:2195'; -- APNS url
v_request_body        RAW(32767);

  -- payload prep
  v_token := '01234567890123456789012345678922';
  v_data := '{ "aps" : { "alert" : "This is the alert text", "badge" : 1, "sound" : "default" }';
  v_data_length := length(v_data);
  
  v_request_body := UTL_RAW.cast_to_raw(0)||
                    UTL_RAW.cast_to_raw(0)||
                    UTL_RAW.cast_to_raw(32)||
                    UTL_RAW.cast_to_raw(v_token)||
                    UTL_RAW.cast_to_raw(0)||
                    UTL_RAW.cast_to_raw(v_data_length)||
                    UTL_RAW.cast_to_raw(v_data);
                    
  v_request_length := UTL_RAW.length(r => v_request_body);
  
  -- request starts here
  UTL_HTTP.set_wallet(path => 'file:/path/wallet', password => 'walletPass');  
  req := UTL_HTTP.BEGIN_REQUEST(url => v_url, method => 'POST');
  UTL_HTTP.SET_HEADER(r     => req,
                      name  => 'Content-Type',
                      value => 'application/octet-stream');
  UTL_HTTP.SET_HEADER(r     => req,
                      name  => 'Content-Length',
                      value => v_request_length);

--  UTL_HTTP.WRITE_TEXT(r => req, data => v_request_body);
  utl_http.write_raw(r => req, data => v_request_body);

  resp := UTL_HTTP.GET_RESPONSE(req);

任何建议将不胜感激!

上面的代码运行后返回这个错误:Fatal SSL Error

与本文类似:ORA-28860: Fatal SSL error when using UTL_HTTP?

该帖子的答案的作者说:

最近11.2.0.4也注册了一个bug 20323753,还没修复。

这是我的版本,但我仍然认为那不是问题。 我可能遗漏了一些关于 APNS 或 PL/SQL 的重要内容

谢谢。

【问题讨论】:

    标签: ios ssl plsql oracle11g apple-push-notifications


    【解决方案1】:

    Zhandos,你有没有让这个工作? 您是否尝试过通过沙箱推送消息? gateway.sandbox.push.apple.com

    此外,我不确定在这里使用 UTL_HTTP 是否是正确的方法,因为这不是 HTTP 服务? 我正在尝试使用 UTL_TCP 来实现相同的目标,尽管我遇到了其他问题来正确设置证书:

    declare
      l_tcp_conn utl_tcp.connection;
      l_returnvalue     number;
    begin
    
      -- open connection
      l_tcp_conn  := utl_tcp.open_connection('gateway.sandbox.push.apple.com', 2195, charset     => 'US7ASCII');
    
      -- secure the connection
      UTL_TCP.SECURE_CONNECTION(l_tcp_conn);
    
      -- write to TCP stream
      l_returnvalue := utl_tcp.write_line(l_tcp_conn, 'payload goes here');
      
    
    end;

    希望这会有所帮助!

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多