Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 3d9c040

Browse files
Fix Android Background Notification #1056
1 parent bbd4954 commit 3d9c040

File tree

3 files changed

+44
-38
lines changed

3 files changed

+44
-38
lines changed

demo/app/main-view-model.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,14 @@ export class HelloWorldModel extends Observable {
965965
}
966966

967967
public doLoginByEmailLink(): void {
968-
prompt(
969-
"The email address to send the link to",
970-
""
971-
).then(promptResult => {
968+
prompt({
969+
title: "The email address to send the link to",
970+
defaultText: "",
971+
inputType: "email",
972+
capitalizationType: "none",
973+
okButtonText: "OK",
974+
cancelButtonText: "Cancel"
975+
}).then(promptResult => {
972976
if (!promptResult.result) {
973977
return;
974978
}
@@ -978,7 +982,7 @@ export class HelloWorldModel extends Observable {
978982
// note that you need to enable phone login in your firebase instance
979983
type: firebase.LoginType.EMAIL_LINK,
980984
emailLinkOptions: {
981-
email: promptResult.text,
985+
email: promptResult.text.trim(),
982986
url: "https://combidesk.com?foo=bar"
983987
}
984988
}).then(

src/firebase.android.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ const dynamicLinksEnabled = lazy(() => typeof (com.google.firebase.dynamiclinks)
8282
url: deepLink,
8383
minimumAppVersion: minimumAppVersion
8484
};
85-
}
86-
else {
85+
} else {
8786
setTimeout(function () {
88-
firebase._dynamicLinkCallback({
89-
url: deepLink,
90-
minimumAppVersion: minimumAppVersion
91-
});
87+
firebase._dynamicLinkCallback({
88+
url: deepLink,
89+
minimumAppVersion: minimumAppVersion
90+
});
9291
});
9392
}
9493
}
@@ -101,11 +100,11 @@ const dynamicLinksEnabled = lazy(() => typeof (com.google.firebase.dynamiclinks)
101100
});
102101

103102
appModule.on(appModule.resumeEvent, args => {
104-
if (messagingEnabled()) {
105-
firebaseMessaging.onAppModuleResumeEvent(args);
106-
}
103+
if (messagingEnabled()) {
104+
firebaseMessaging.onAppModuleResumeEvent(args);
105+
}
107106
});
108-
})();
107+
})();
109108

110109
firebase.toHashMap = obj => {
111110
const node = new java.util.HashMap();
@@ -590,7 +589,7 @@ firebase.getRemoteConfig = arg => {
590589
runGetRemoteConfig();
591590
appModule.off(appModule.resumeEvent, callback);
592591
};
593-
appModule.on(appModule.resumeEvent, callback);
592+
appModule.on(appModule.resumeEvent, callback);
594593
}
595594
} catch (ex) {
596595
console.log("Error in firebase.getRemoteConfig: " + ex);

src/messaging/messaging.android.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,34 @@ export function onAppModuleResumeEvent(args: any) {
5050

5151
const intent = args.android.getIntent();
5252
const extras = intent.getExtras();
53-
// filter out any rubbish that doesn't have a 'from' key
54-
if (extras !== null && extras.keySet().contains("from")) {
55-
let result = {
56-
foreground: false,
57-
data: {}
58-
};
59-
60-
const iterator = extras.keySet().iterator();
61-
while (iterator.hasNext()) {
62-
const key = iterator.next();
63-
if (key !== "from" && key !== "collapse_key") {
64-
result[key] = extras.get(key);
65-
result.data[key] = extras.get(key);
66-
}
67-
}
6853

69-
if (firebase._receivedNotificationCallback === null) {
70-
_launchNotification = result;
71-
} else {
72-
// add a little delay just to make sure clients alerting this message will see it as the UI needs to settle
73-
setTimeout(() => {
74-
firebase._receivedNotificationCallback(result);
75-
});
54+
if (extras !== null && extras.keySet().contains("from")) {
55+
let result = {
56+
foreground: false,
57+
data: {}
58+
};
59+
60+
const iterator = extras.keySet().iterator();
61+
while (iterator.hasNext()) {
62+
const key = iterator.next();
63+
if (key !== "from" && key !== "collapse_key") {
64+
result[key] = extras.get(key);
65+
result.data[key] = extras.get(key);
7666
}
7767
}
68+
69+
// clear, otherwise the next resume we trigger this again
70+
intent.removeExtra("from");
71+
72+
if (firebase._receivedNotificationCallback === null) {
73+
_launchNotification = result;
74+
} else {
75+
// add a little delay just to make sure clients alerting this message will see it as the UI needs to settle
76+
setTimeout(() => {
77+
firebase._receivedNotificationCallback(result);
78+
});
79+
}
80+
}
7881
}
7982

8083
export function registerForInteractivePush(model?: PushNotificationModel): void {

0 commit comments

Comments
 (0)