#Notifications callbacks not being called on iOS #notifications
1 messages · Page 1 of 1 (latest)
We had an issue where unity changed the callback method names but it was fixed and pushed to stores.
Can you please share the following files?
AppDelegateListener.mm and NPAppDelegateListener.mm along with your unity version?
Using Unity 2020.3.43f1
I see.
Did you try our NotificationServicesDemo Scene and see any messages on receiving notification?
nope, as I told, I have been using the VB plugin since years, so not needed to use demo scene
Ok, can you please try it once?
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
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
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
What is your device version?
iPhone 11, iOS 16.1.1
Thank you!
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
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
Can you pls send me a screenshot of xcode capabilities push notifications section
Do you have unity's mobile notifications package installed in your unity project?
I checked it. Yes
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 .
Please share me the payload info.
Earlier versions there was an issue on how it used to handle userinfo
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'}"}
where is user_info key value?
we don;t sent any user_info, the information in notification_data became the user_info
Do you use fcm on iOS?
no
These are our expected payload formats
https://assetstore.essentialkit.voxelbusters.com/notification-services/faq#what-are-some-payload-formats-for-reference
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:
There was an issue ealier but it was fixed and now user_info returns the correct values when pass in above format.
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;
}
Can you pls share me the payload you send now?
the user_info in our case doesn't valid with NSJSONSerialization
Do you pass stringified json? Or a json struct for user_info?
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'}"}
Here user_info is a stringified json. So it fails i suppose.
Can you pass it as json instead and see?
actually, can't change at server as of now.
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
it seems workable. will test when ever possible.