I have read this answer: PLSQL APPLE push notifiactions
我已经读过这个答案:PLSQL APPLE推送notifiactions
but I cannot use Java. I believe there should be a way to contact APNS from PL/SQL, because I have already implemented GCM(Android notifications) using PL/SQL.
但我不能使用Java。我相信应该有一种方法可以从PL / SQL联系APNS,因为我已经使用PL / SQL实现了GCM(Android通知)。
How certificates are set up: I have one pem file which contains Apple Push Certificate and Private key. I also have entrust's root certificate. I added them to the wallet using orapki.
如何设置证书:我有一个pem文件,其中包含Apple推送证书和私钥。我也有委托的根证书。我使用orapki将它们添加到钱包中。
I am not good at PL/SQL, so there might be some problem in my code:
我不擅长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);
Any suggestions would be appreciated!
任何建议,将不胜感激!
The code above after run returns this Error: Fatal SSL Error
运行后的上面的代码返回此错误:致命的SSL错误
Similar as in this post: ORA-28860: Fatal SSL error when using UTL_HTTP?
与此文章类似:ORA-28860:使用UTL_HTTP时发生致命SSL错误?
The author of the answer to that post says:
该帖子答案的作者说:
There is also a bug 20323753 registered for 11.2.0.4 recently, still not fixed.
最近还有一个针对11.2.0.4注册的错误20323753,仍然没有修复。
Thats the version I have, but I still think thats not the problem. I might be missing something important about APNS or PL/SQL
这是我的版本,但我仍然认为这不是问题。我可能会遗漏一些关于APNS或PL / SQL的重要信息
Thanks.
1 个解决方案
#1
Zhandos, did you ever get this to work? Have you tried pushing messages through the sandbox? gateway.sandbox.push.apple.com
Zhandos,你有没有得到这个工作?您是否尝试过通过沙箱推送消息? gateway.sandbox.push.apple.com
Further, I'm not sure whether using UTL_HTTP is the correct approach here, as this is not a HTTP service? I'm trying to achieve the same using UTL_TCP, although I'm having other issues to get set the certificate correct:
此外,我不确定在这里使用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;
Hope this helps!
希望这可以帮助!
Thanks.
#1
Zhandos, did you ever get this to work? Have you tried pushing messages through the sandbox? gateway.sandbox.push.apple.com
Zhandos,你有没有得到这个工作?您是否尝试过通过沙箱推送消息? gateway.sandbox.push.apple.com
Further, I'm not sure whether using UTL_HTTP is the correct approach here, as this is not a HTTP service? I'm trying to achieve the same using UTL_TCP, although I'm having other issues to get set the certificate correct:
此外,我不确定在这里使用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;
Hope this helps!
希望这可以帮助!
Thanks.