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

Commit d404323

Browse files
Merge pull request #281 from dbenninger/master
Fix app crash when notification structure is missing
2 parents dd5a4a2 + 44d2ad6 commit d404323

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

firebase.ios.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,14 @@ firebase._registerForRemoteNotifications = function () {
257257
curNotCenter.delegate = firebase._userNotificationCenterDelegate;
258258

259259
firebase._firebaseRemoteMessageDelegate = FIRMessagingDelegateImpl.new().initWithCallback(function (appDataDictionary) {
260-
var asJs = firebase.toJsObject(appDataDictionary.objectForKey("notification"));
261-
262260
var userInfoJSON = firebase.toJsObject(appDataDictionary);
263261
firebase._pendingNotifications.push(userInfoJSON);
264262

265-
userInfoJSON.title = asJs.title;
266-
userInfoJSON.body = asJs.body;
263+
var asJs = firebase.toJsObject(appDataDictionary.objectForKey("notification"));
264+
if(asJs) {
265+
userInfoJSON.title = asJs.title;
266+
userInfoJSON.body = asJs.body;
267+
}
267268

268269
var app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
269270
if (app.applicationState === UIApplicationState.UIApplicationStateActive) {

0 commit comments

Comments
 (0)