Skip to content

Commit 7831722

Browse files
dadachiclaude
andauthored
Connect to APNs sandbox server in development (#74)
config/push.yml left connect_to_development_server commented out, so the gem connected to the production APNs host in every environment. A Xcode debug build registers a sandbox device token; pushing it to production APNs returns 400 BadDeviceToken, which the gem raises as TokenError and then destroys the device via the default rescue_from. The visible symptom was an iOS device record vanishing as soon as any notification fired (e.g. an Android client completing an item_tag). Enable the gem's recommended default so local development talks to the APNs sandbox while staging/production use the production host. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5b0e314 commit 7831722

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

config/push.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ shared:
2626
# Please note that anything built directly from Xcode and loaded on your phone will have
2727
# the app generate DEVELOPMENT tokens, while everything else (TestFlight, Apple Store, ...)
2828
# will be considered as PRODUCTION environment.
29-
# connect_to_development_server: <%= Rails.env.development? %>
29+
#
30+
# Without this, the gem defaults to the production APNs server. A Xcode
31+
# debug build registers a sandbox token, and pushing it to the production
32+
# server returns 400 BadDeviceToken, which the gem treats as TokenError and
33+
# destroys the device. Match the server to the Rails environment so local
34+
# development talks to the sandbox.
35+
connect_to_development_server: <%= Rails.env.development? %>
3036

3137
# Use bin/rails credentials:edit to set the fcm secrets under
3238
# action_push_native:fcm:{project_id, encryption_key}.

test/config/push_config_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "test_helper"
2+
3+
class PushConfigTest < ActiveSupport::TestCase
4+
test "apns connects to the sandbox server only in the development environment" do
5+
config = ActionPushNative.config
6+
7+
assert config.key?(:apple), "expected push.yml to configure the :apple platform"
8+
assert_equal Rails.env.development?, config.dig(:apple, :connect_to_development_server)
9+
end
10+
end

0 commit comments

Comments
 (0)