port of apns logic update from personal repo