Pretty hacky flow, but this will remove anyone that was invited but not accepted their TestFlight invitation.
Start the Ruby REPL
$ irb
Setup your environment and select the your team
require "spaceship"
Spaceship::Tunes.login("[email protected]", "password")
Spaceship::Tunes.select_team
Set variables you'll need
app = Spaceship::ConnectAPI::App.find("COM.YOUR.APP.ID")
Then get all the users
testers = app.get_beta_testers(includes: "betaTesterMetrics,betaGroups", limit: 200)
Go to App Store Connect. Keep scrolling and loading builds at the bottom of the page until there are no more builds. This will show the last-unexpired build.
The last build should say something like "Expires in 4 days".
In irb
, set the last-unexpired build.
last_build = 1
Filter testers that should be removed:
- Users in the
Beta
group and last-status is over 2 weeks (avoid removing anyone just-invited) - Users on an expired build.
- Note that
to_i
will be 0 for users that have not accepted an invitation. This will also then automatically remove people who have not accepted an invite in over 2 weeks.
- Note that
> remove_testers = testers.select{ |t| \
t.beta_groups.first.name == "YOUR_BETA_GROUP_NAME" \
&& ((Time.now - Time.parse(t.beta_tester_metrics.first.last_modified_date)) / 60.0 / 60.0 / 24.0) > 14 \
&& t.beta_tester_metrics.first.installed_cf_bundle_version.to_i < last_build \
}
To check how many users you will remove
remove_testers.length()
Then remove them from TestFlight
remove_testers.each{|t| t.delete_from_apps(apps: [app]) }
Done!