Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add support for Iterable Push notifications with Open URL open action behaviour on iOS. #66

Merged

Conversation

mabidakun
Copy link
Contributor

@mabidakun mabidakun commented Aug 21, 2023

What it does

  • Makes SwiftIterableFlutterPlugin class conform to the IterableURLDelegate protocol so that it can receive and propagate Iterable push notifications that are configured with the "Open URL" action.
    • With this change in place, the openedNotificationHandler in the Flutter application will now also be called for Iterable push notifications that are set-up in Iterable as having the Open action behaviour type set to "Open URL".
      Prior to this change, the Flutter application would not be called when configured as "Open URL" so deep-link use cases were not supported.

How to test (Unit test)

  1. From the command line, run the unit tests :- $ flutter test.
  2. Observe that the result of running the tests contains the following line: All tests passed!

How to test (iOS)

Having configured the application as per iterable_flutter instructions, and with the openedNotificationHandler also set in your Flutter code :-

  1. Login to Iterable's website and create an Iterable Push notification campaign with the Open action behaviour set to "Open URL".
    SCR-20230821-isrj-2
  2. Save the campaign changes.
  3. Tap the "Send test message" button, to send the push notification to a specified user/device.
    SCR-20230821-itkk-2
  4. Observe that your openedNotificationHandler is called with the url specified in the campaign as follows :-
{
	"title": "...",
	"body": "...",
	"additionalData": {
		"itbl": {
			"messageId": "",
			"defaultAction": {
				"type": "openUrl",
				"data": "https://example.com/your/path/here?a=b"
			},
			"aps": {}
		},
		"url": "https://example.com/your/path/here?a=b"
	}
}

Notes:

  • When received on Android, it was observed that the additionalData.url key was actually additionalData.uri.
  • For safety, simply use the key additionalData.itbl.defaultAction.data, to retrieve the url (although on Android, this seems to be delivered as a JSON string, rather than an a Dictionary/Map/Associative array).

…onditions (using guard let), before continuing.
… protocol so that it can receive and propagate Iterable push notifications that are configured with the "Open URL" action.

With this change in place, the openedNotificationHandler in the Flutter application will now also be called for Iterable push notifications that are set-up in Iterable as having the Open action behaviour type set to "Open URL".
Prior to this change, the Flutter application would not be called when configured as "Open URL" so deep-link use cases were not supported.
Re-uses the userInfo reference to IterableAPI.lastPushPayload, since we have it.
Copy link
Contributor

@cdmunoz cdmunoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, this LGTM 👌🏻

Although I'm wondering if this change breaks some previous behavior ... did you have the chance to test it? could you?

@mabidakun
Copy link
Contributor Author

mabidakun commented Aug 22, 2023

So far, this LGTM 👌🏻

Although I'm wondering if this change breaks some previous behavior ... did you have the chance to test it? could you?

Hi @cdmunoz - Great question.

So, this change is purely additive - with no existing behaviour being changed (the changes in notifyPushNotificationOpened are just more idiomatic Swift style - using guard to ensure everything we need for the subsequent operation, is assigned and ready to go).

Beyond that, the change simply assigns a URL delegate on the IterableConfig instance, were one was previously not being assigned.

Please see Iterable's Deep Links in Push Notifications documentation :-

SCR-20230822-nzzr-2


Regarding testing - as far as I am aware, everything continues to work as it did before (I did test it 😊) - our app was working with both the OpenApp and the Custom open action behaviours, but our marketing team chose to use OpenURL, which was not implemented in iterable_flutter. These other action types continue to work as before.

@mabidakun mabidakun changed the title Chore: Add support for Iterable Push notifications with "Open URL" open action behaviour on iOS. Chore: Add support for Iterable Push notifications with Open URL open action behaviour on iOS. Aug 22, 2023
@mabidakun
Copy link
Contributor Author

mabidakun commented Aug 22, 2023

Hey @cdmunoz - Thanks for approving. 💯

I meant to say earlier, thanks for writing this plugin. It is a life saver!

I'll leave it for you guys to merge (my company's project is currently pointing at my fork, until this change is in your release).

Thanks again.

-- Mike. 🤓

@cdmunoz cdmunoz merged commit bcd372d into la-haus:master Aug 23, 2023
4 checks passed
@mabidakun mabidakun deleted the chore/Add-Support-for-OpenURL-Action branch February 24, 2024 11:39
@mabidakun mabidakun restored the chore/Add-Support-for-OpenURL-Action branch February 25, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants