#Notifications callbacks not being called on iOS #notifications

1 messages · Page 1 of 1 (latest)

loud grotto
#

We have been using the plugin since many years and it has been working well. recently moved to XCode 15 and the issue seems to be started after that. We are not receiving callbacks like "OnNotificationReceived" on iOS (on local and push both). Its fine on Android.
Upgdared to VB#2.7 but same issue

jovial plover
loud grotto
jovial plover
#

I see.

#

Did you try our NotificationServicesDemo Scene and see any messages on receiving notification?

loud grotto
#

nope, as I told, I have been using the VB plugin since years, so not needed to use demo scene

jovial plover
#

Ok, can you please try it once?

loud grotto
#

ok

#

Tried with demo scene, sent on push notifications, which opened the app but when there was no UI for clicked notification. I checked then GetDeleiveredNotification, that also said 0 notifications received

jovial plover
#

Try sending a local notification (Schedule Now) and see in the console log (within the demo app) an event. If the event is received let me know

loud grotto
#

I schedule a notification, it said in the log "Request to schedule the notification finished successfully". I set the interval as 1

#

no notification is trigger yet

jovial plover
#

What is your device version?

loud grotto
#

iPhone 11, iOS 16.1.1

jovial plover
#

I see.

#

Strange. I can receive them as expected.

#

Let me look into it.

loud grotto
#

Thank you!

loud grotto
#

FYI, I was debuging and see that none of these functions - (void)userNotificationCenter:(UNUserNotificationCenter*)center willPresentNotification:(UNNotification*)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler is getting called when the app opens by notifications

loud grotto
#

Another point noriced. Only function found which is getting called on push notification click is UnityNotificationManager's - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(nonnull void(^)(void))completionHandler

jovial plover
#

Can you pls send me a screenshot of xcode capabilities push notifications section

loud grotto
jovial plover
#

Do you have unity's mobile notifications package installed in your unity project?

loud grotto
#

I checked it. Yes

loud grotto
#

It worked after removing the mobile notifications package, but had to back tracked to VB version #2.5, because in the latest verion the UserInfo object of the INotification is always coming as NULL in iOS .

jovial plover
#

Please share me the payload info.

#

Earlier versions there was an issue on how it used to handle userinfo

loud grotto
#

plz find it here: {"aps": {"alert": "test 104 coin", "sound": "default", "badge": 1}, "pn_ttl": 86400, "notification_data": "{'id': 0, 'coins': 11111, 'url_action': True, 'additional_action': {'count': 11111, 'name': 'send_coins'}, 'push_id': '665edb74710347322f28d92a'}"}

jovial plover
#

where is user_info key value?

loud grotto
#

we don;t sent any user_info, the information in notification_data became the user_info

jovial plover
#

Do you use fcm on iOS?

loud grotto
#

no

loud grotto
#

Made it like that, even its comming NULL. checked the internal code and found that plugin code is not able to convert and parse the user_info json.

#

I recalled that I had to change Plugin code previously too, I wonder why anybody else is not having same issue.

#

Anyways, below are the changes had to made:

jovial plover
#

There was an issue ealier but it was fixed and now user_info returns the correct values when pass in above format.

loud grotto
#

ok, but its the same issue for me as was in older version.

#

had to change NPBindingHelper::NPToJson function

#

NSString* NPToJson(id object, NSError** error)
{
if ([NSJSONSerialization isValidJSONObject: object])
{
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:object
options:0
error:error];

    if (*error == nil)
    {
        return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
}else{
    return (NSString*)(object);
}

return nil;

}

jovial plover
#

Can you pls share me the payload you send now?

loud grotto
#

the user_info in our case doesn't valid with NSJSONSerialization

jovial plover
#

Do you pass stringified json? Or a json struct for user_info?

loud grotto
#

1 min

#

this is sample from server payload: {"aps": {"alert": "test 104", "sound": "default", "badge": 0}, "pn_ttl": 86400, "user_info": "{'id': 0, 'coins': 104, 'url_action': true, 'additional_action': {'count': 104, 'name': 'send_coins'}, 'push_id': '665d94326470d51dcafe0b7c'}"}

jovial plover
#

Here user_info is a stringified json. So it fails i suppose.

#

Can you pass it as json instead and see?

loud grotto
#

actually, can't change at server as of now.

jovial plover
#

Oh ok.

#

I can fallback to take as a string. May be that fixes your case.

loud grotto
#

yes, see thats like what I changed above

#

but than also needed to code the UserInfoStr property of the notification, it was there in prevous version but missed in the latest one

#

not sure why, but even I we pass user_info as string, the c# function which convert it UserInfo string into Dictionary, does parse and UserInfo still be NULL, so I pass the USerInfo string as in UserInfoString function

loud grotto