###前提・実現したいこと
バッチ(Ruby)で、AWSのSNSを使用してエンドポイントへpush通知を行う処理があり、
3年ほど問題なく動いていたのですが、ここ数ヶ月でpush通知がきていないと報告がありました。
サーバの実行ログを確認したのですが、正常に処理が完了しているように思います。
※処理で例外が発生するとエラーとしてログに出力されるのですが、出力はなかった為、正常に処理しているとみなしております
サーバとスマートフォンのどちらに原因があるかの切り分け方、
またSNSの送信ログの確認の仕方をご教示頂けないでしょうか?
###該当のソースコード
ruby
1require 'aws-sdk' 2 3$config = YAML.load( File.read("../config.yml") ) 4AWS.config({ 5 :access_key_id => $config['aws']['access_key_id'], 6 :secret_access_key => $config['aws']['secret_access_key'], 7 :region => $config['aws']['region'] 8}) 9$client = AWS::SNS.new.client 10 11# エンドポイントへpush通知送信 12def push2endpoints(endpoints) 13 now = Time.now 14 15 endpoints[:endpoints].each do |endpoint| 16 begin 17 if ARGV[1] == 'iphone' 18 $client.publish( 19 target_arn: endpoint[:endpoint_arn], 20 message: $message 21 ) 22 else 23 android_json = JSON.load( $message ) 24 $client.publish( 25 target_arn: endpoint[:endpoint_arn], 26 message: android_json.to_json 27 ) 28 end 29 $logger.info "[push endpoint]: #{ endpoint[:endpoint_arn] }" 30 rescue => err 31 next 32 $logger.error err 33 end 34 end 35end 36 37# 2階目以降のpush通知送信 38def push_next_endpoints(next_token) 39 begin 40 (exit 0) if next_token.nil? 41 endpoints = $client.list_endpoints_by_platform_application( 42 platform_application_arn: $platform_application_arn, 43 next_token: next_token 44 ) 45 push2endpoints(endpoints) 46 47 if endpoints[:next_token] 48 push_next_endpoints(endpoints[:next_token]) 49 end 50 rescue => err 51 $logger.error err 52 exit 1 53 end 54end 55 56# 特定のアプリのEndpointを全て取得して、すべての端末にプッシュ通知 57endpoints = $client.list_endpoints_by_platform_application( 58 platform_application_arn: $platform_application_arn 59) 60push2endpoints(endpoints) 61 62push_next_endpoints(endpoints[:next_token])
###試したこと
AWS - SNS - Text messaging (SMS) - Account stats で、
Transactional、Promotionalのsentが0のことを確認。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。