OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
616 stars 213 forks source link

[Bug]: InApp messages click handler is not working in iOS #633

Closed MuhammedRefaat closed 6 months ago

MuhammedRefaat commented 1 year ago

What happened?

I'm using Flutter SDK for sending InApp messages to my Flutter app, and using triggers to trigger these messages on certain occasions. I've implemented everything according to the documentation, and created the required message template in the dashboard, but when triggering the inApp message and making any action on it the corresponding action listener setInAppMessageClickedHandler is not getting fired at all in iOS. Then I tried to add other listeners like setOnWillDismissInAppMessageHandler or setOnDidDisplayInAppMessageHandler but non of them got fired.

Worth to mention that everything is working perfectly in android and all the listeners are working properly. Worth to mention also that upon clicking on the action in the message, I'm getting some logs that seems to catch the inApp message actions but they are not implemented anywhere in my app (you can find them below in the logs section).

Related code:

OneSignal.shared
        .setInAppMessageClickedHandler((OSInAppMessageAction action) {
          //  NEVER CALLED in iOS
    });

Steps to reproduce?

1. Add a new InApp message using OneSignal dashboard and assign its actions as required.
2. Register the device as a message receiver.
3. Add a trigger into the device to fire the InApp message once the user do a specific action.
   (for example 'OneSignal.shared.addTrigger('live', 'true');)
4. Get the InApp message shown in the application.
5. Make an action.

What did you expect to happen?

Once doing the action, the message should be dismissed and the inAppMessageHandler should be triggered, but instead nothing happen.

OneSignal Flutter SDK version

onesignal_flutter: ^3.4.1

Which platform(s) are affected?

Relevant log output

VERBOSE: Received in-app script message: {"type":"action_taken","body":{"id":"d5c259cd-c9dc-46e7-ba84-34b996d2cf45","name":"maybe","close":true,"prompts":[],"url_target":"browser","click_type":"button"}}
VERBOSE: OSInAppMessageAction {
"click_type" = button;
close = 1;
id = "d5c259cd-c9dc-46e7-ba84-34b996d2cf45";
name = maybe;
prompts = (
);
"url_target" = browser;
}
VERBOSE: Action Occured with Event: OSInAppMessageBridgeEvent type: 1
renderingComplete: (null)
resize: (null)
userAction: OSInAppMessageAction outcome: (
)
tag: (null) promptAction: (
)
VERBOSE: Action Occured with Event Type: 1
DEBUG: OneSignal SessionManager onDirectInfluenceFromIAMClick messageId: 401159a7-3ac6-4adf-9c16-042d38e112e8
DEBUG: OSChannelTracker changed: iam_id
from:
influenceType: INDIRECT
, directId: (null)
, indirectIds: (
"401159a7-3ac6-4adf-9c16-042d38e112e8"
)
to:
influenceType: DIRECT
, directId: 401159a7-3ac6-4adf-9c16-042d38e112e8
, indirectIds: (null)
DEBUG: Trackers changed to: (
"OSChannelTracker tag: notification_id influenceType: UNATTRIBUTED indirectIds: (null) directIds: (null)",
"OSChannelTracker tag: iam_id influenceType: DIRECT indirectIds: (null) directIds: 401159a7-3ac6-4adf-9c16-042d38e112e8"
)
VERBOSE: HTTP Request (OSRequestInAppMessageClicked) with URL: https://api.onesignal.com/in_app_messages/401159a7-3ac6-4adf-9c16-042d38e112e8/click, with parameters: {
"first_click" : false,
"variant_id" : "c41f563a-9438-41a0-bd46-c621801d3794",
"player_id" : "13f4df01-dd7e-4c15-a1fd-8703d6692c64",
"app_id" : "414e7836-a1dc-4a61-a4fd-82584ed0d115",
"click_id" : "d5c259cd-c9dc-46e7-ba84-34b996d2cf45",
"device_type" : 0
}
VERBOSE: network response (OSRequestInAppMessageClicked): {
success = 1;
}
DEBUG: In App Message with id: 401159a7-3ac6-4adf-9c16-042d38e112e8, successful POST click update for click id: d5c259cd-c9dc-46e7-ba84-34b996d2cf45, with result: {
success = 1;
}
VERBOSE: Dismissing IAM and preparing to show next IAM
DEBUG: OneSignal SessionManager onDirectInfluenceFromIAMClickFinished
DEBUG: OSChannelTracker for: iam_id lastChannelObjectReceived: (
"OSIndirectInfluence channelIdTag: iam_id Id: 401159a7-3ac6-4adf-9c16-042d38e112e8 Timestamp: 1672931468.256848"
)
DEBUG: OSChannelTracker resetAndInitInfluence for: iam_id finish with influenceType: INDIRECT
VERBOSE: Dismissing IAM save seenInAppMessages: {(
"401159a7-3ac6-4adf-9c16-042d38e112e8"
)}
VERBOSE: redisplayedInAppMessages: {
"401159a7-3ac6-4adf-9c16-042d38e112e8" = "OSInAppMessage: \nmessageId: 401159a7-3ac6-4adf-9c16-042d38e112e8 \ntriggers: (\n (\n \"OSTrigger: triggerId=9b5b71b0-019a-405c-9a7c-598a561ddda6 kind=custom property=story operatorType=2 value=true\"\n )\n) \ndisplayed_in_session: YES \ndisplayStats: OSInAppMessageDisplayStats: redisplayEnabled: YES \nlastDisplayTime: 1672931473.908873 \ndisplayDelay: 0.000000 \ndisplayQuantity: 41 \ndisplayLimit: 2147483647 \nendTime: (null) \nhasLiquid: NO";
}
VERBOSE: persistInAppMessageForRedisplay: OSInAppMessage:
messageId: 401159a7-3ac6-4adf-9c16-042d38e112e8
triggers: (
(
"OSTrigger: triggerId=9b5b71b0-019a-405c-9a7c-598a561ddda6 kind=custom property=story operatorType=2 value=true"
)
)
displayed_in_session: YES
displayStats: OSInAppMessageDisplayStats: redisplayEnabled: YES
lastDisplayTime: 1672931473.908873
displayDelay: 0.000000
displayQuantity: 41
displayLimit: 2147483647
endTime: (null)
hasLiquid: NO
redisplayedInAppMessages: {
"401159a7-3ac6-4adf-9c16-042d38e112e8" = "OSInAppMessage: \nmessageId: 401159a7-3ac6-4adf-9c16-042d38e112e8 \ntriggers: (\n (\n \"OSTrigger: triggerId=9b5b71b0-019a-405c-9a7c-598a561ddda6 kind=custom property=story operatorType=2 value=true\"\n )\n) \ndisplayed_in_session: YES \ndisplayStats: OSInAppMessageDisplayStats: redisplayEnabled: YES \nlastDisplayTime: 1672931473.908873 \ndisplayDelay: 0.000000 \ndisplayQuantity: 41 \ndisplayLimit: 2147483647 \nendTime: (null) \nhasLiquid: NO";
}
VERBOSE: persistInAppMessageForRedisplay saved redisplayedInAppMessages: {
"401159a7-3ac6-4adf-9c16-042d38e112e8" = "OSInAppMessage: \nmessageId: 401159a7-3ac6-4adf-9c16-042d38e112e8 \ntriggers: (\n (\n \"OSTrigger: triggerId=9b5b71b0-019a-405c-9a7c-598a561ddda6 kind=custom property=story operatorType=2 value=true\"\n )\n) \ndisplayed_in_session: YES \ndisplayStats: OSInAppMessageDisplayStats: redisplayEnabled: YES \nlastDisplayTime: 1672931473.908873 \ndisplayDelay: 0.000000 \ndisplayQuantity: 41 \ndisplayLimit: 2147483647 \nendTime: (null) \nhasLiquid: NO";
}
VERBOSE: Evaluating message display queue
VERBOSE: Evaluating in app messages
Redisplay dismissed: YES and data: {
messageId = "401159a7-3ac6-4adf-9c16-042d38e112e8";
redisplay = {
delay = 0;
limit = 2147483647;
};
triggers = (
(
{
id = "9b5b71b0-019a-405c-9a7c-598a561ddda6";
kind = custom;
operator = equal;
property = story;
value = true;
}
)
);
variants = {
all = {
default = "c41f563a-9438-41a0-bd46-c621801d3794";
};
};
}
Redisplay IAM: {
messageId = "401159a7-3ac6-4adf-9c16-042d38e112e8";
redisplay = {
delay = 0;
limit = 2147483647;
};
triggers = (
(
{
id = "9b5b71b0-019a-405c-9a7c-598a561ddda6";
kind = custom;
operator = equal;
property = story;
value = true;
}
)
);
variants = {
all = {
default = "c41f563a-9438-41a0-bd46-c621801d3794";
};
};
}
VERBOSE: setDataForRedisplay with message: OSInAppMessage:
messageId: 401159a7-3ac6-4adf-9c16-042d38e112e8
triggers: (
(
"OSTrigger: triggerId=9b5b71b0-019a-405c-9a7c-598a561ddda6 kind=custom property=story operatorType=2 value=true"
)
)
displayed_in_session: YES
displayStats: OSInAppMessageDisplayStats: redisplayEnabled: YES
lastDisplayTime: 1672931473.908873
displayDelay: 0.000000
displayQuantity: 41
displayLimit: 2147483647
endTime: (null)
hasLiquid: NO
triggerHasChanged: NO
no triggers: NO
displayed in session saved: YES

Code of Conduct

brismithers commented 1 year ago

@MuhammedRefaat unfortunately I haven't been able to reproduce this. I am using the example app, and setting an IAM to fire on app open, all IAM-related callbacks are being called.

One thing to try is to call OneSignal.shared.setInAppMessageClickedHandler prior to OneSignal.shared.setAppId to ensure the handler has been setup before the IAM has been shown. If this does not resolve it, would you be able to provide a sample repo which reproduces the error you're seeing?

Thanks!

mturcic commented 1 year ago

We're having the exact issue in our project as well.

Tried calling the OneSignal.shared.setInAppMessageClickedHandler before setAppId and nothing changes

jennantilla commented 6 months ago

Hello everyone! Apologies that this issue has gone stale.

I'd like to request that everyone update to our latest major release of the Flutter SDK which includes many improvements and enhancements. Please refer to our migration guide for full details on upgrading.

If this issue still persists after the update, please open a new issue and we can continue investigation.

Thanks!