Skip to content

Commit bae81e2

Browse files
committed
Deprecate debug mode for APNS
* Debug mode was introduced for demo purposes before push notifications services was integrated to the apps. * This was a workaround for the fact that production was supposed to use silent notifications but we needed a way to verify that notifications are sent for development purposes. * It showed a visible debug alert with a timestamp for specific topics only. * iOS app is not going to use silent notifications in production because they don't work as planned but instead override the alert message of the apns payload Change-Id: I337ed591be40703931ee151fa18229490893909c Bug: T287897
1 parent 1fc9c66 commit bae81e2

File tree

5 files changed

+3
-63
lines changed

5 files changed

+3
-63
lines changed

config.dev.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ services:
8282
# Apple Push Notification Service configuration
8383
apns:
8484
mock: true
85-
# Topics for which user-visible notifications should be displayed
86-
# debug_topics:
87-
# - org.wikimedia.Notifications-Utility
8885
# Queueing options. If defined, requests will be enqueued according to the specified options
8986
# rather than immediately sent.
9087
queueing:

config.test.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ services:
8282
# Apple Push Notification Service configuration
8383
apns:
8484
mock: true
85-
# Topics for which user-visible notifications should be displayed
86-
# debug_topics:
87-
# - org.wikimedia.Notifications-Utility
8885
# Queueing options. If defined, requests will be enqueued according to the specified options
8986
# rather than immediately sent.
9087
queueing:

src/outgoing/apns/apns.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,8 @@ export async function sendMessage(app: Application, message: MultiDeviceMessage)
129129
notification.payload = { data: { type: message.type } };
130130
notification.threadId = message.type;
131131
notification.topic = message.meta.topic;
132-
const hasDebugTopics = app.conf.apns.debug_topics && app.conf.apns.debug_topics.length;
133-
if (hasDebugTopics && app.conf.apns.debug_topics.includes(notification.topic)) {
134-
notification.mutableContent = true;
135-
notification.alert = `Message sent at ${transactionStart}`;
136-
}
132+
notification.alert = message.type;
133+
notification.mutableContent = true;
137134
const response: Responses = await apn.send(notification, [...message.deviceTokens]);
138135
apn.shutdown();
139136
app.logger.log('debug/apns', `Successfully sent ${(response.sent.length)} messages; ` +

src/outgoing/apns/readme.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ This is targeting push notifications on Safari desktop. To send an APNS notifica
7373
* Visit `/?doc#/Push notifications/post_v1_message_apns` on `push-notifications` service and trigger
7474
an API request after replacing the token under `deviceTokens`.
7575

76-
#### iOS demo app
77-
78-
A demo iOS app is available at https://github.com/wikimedia/notifications-utility-ios. The app
79-
can be installed on a testing device either directly via XCode or using TestFlight. The app will
80-
display a token which can be used to send messages through the service.
81-
82-
To have the demo app display user-visible notifications, update the service `apns` configuration to
83-
include the app identifier in the list of `debug_topics`:
84-
85-
```
86-
apns:
87-
debug_topics:
88-
- org.wikimedia.Notifications-Utility
89-
```
90-
This will modify the message payload so that the demo app displays a notification rather than
91-
silently processing the message.
92-
9376
### Production
9477

9578
The app is expecting the `.p8` token key named `apns.p8` to exist under

test/unit/outgoing/apns/apns.spec.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const apnsRewired = rewire('../../../../src/outgoing/apns/apns.ts');
1717
describe('unit:APNS', () => {
1818
const logger = new Logger();
1919
const app: any = {
20-
conf: { apns: { mock: true, debug_topics: ['debug_client'] } },
20+
conf: { apns: { mock: true } },
2121
logger
2222
};
2323
let sandbox;
@@ -73,40 +73,6 @@ describe('unit:APNS', () => {
7373
assert.deepEqual(spy.firstCall.args[0].headers, expectedHeaders);
7474
});
7575

76-
it('send APNS message with debug topic', async () => {
77-
const meta = {
78-
topic: 'debug_client'
79-
};
80-
const spy = sandbox.spy(MockClient.prototype, 'write');
81-
await sendMessage(app, new MultiDeviceMessage(
82-
new Set(['TOKEN']),
83-
PushProvider.APNS,
84-
MessageType.CheckEchoV1,
85-
meta,
86-
false
87-
));
88-
sinon.assert.calledOnce(spy);
89-
const body = JSON.parse(spy.firstCall.args[0].body);
90-
assert.deepEqual(body.aps.alert.startsWith('Message sent at'), true);
91-
});
92-
93-
it('send APNS message without debug topic', async () => {
94-
const meta = {
95-
topic: 'not_debug_client'
96-
};
97-
const spy = sandbox.spy(MockClient.prototype, 'write');
98-
await sendMessage(app, new MultiDeviceMessage(
99-
new Set(['TOKEN']),
100-
PushProvider.APNS,
101-
MessageType.CheckEchoV1,
102-
meta,
103-
false
104-
));
105-
sinon.assert.calledOnce(spy);
106-
const body = JSON.parse(spy.firstCall.args[0].body);
107-
assert.deepEqual('alerts' in body, false);
108-
});
109-
11076
it('send APNS message with undefined topic', async () => {
11177
const meta = {};
11278
const spy = sandbox.spy(MockClient.prototype, 'write');

0 commit comments

Comments
 (0)