Refactor ApnsPlugin.