-- Shows dialog with two buttons
-- App receives `ReceivePushPrePromptResponse` message when user taps a button,
-- with a `Result` containing a boolean that corresponds to the value of the tapped button
Task.attempt ReceivePushPrePromptResponse <|
NativeUi.alert
"This is what it sounds like when trains cry"
"Purple Train can send you notifications when your trains are cancelled!"
[ { text = "Not Now", value = False }
, { text = "Give Access", value = True }
]
-- Handling result from ReceivePushPrePromptResponse in the update function:
case result of
Ok True ->
-- register function kicks off a task that shows the system permission dialog
-- Calls update with the ReceivePushToken message with a Result of either:
-- Ok (with the device push token) or Err (with the registration error)
Task.attempt ReceivePushToken PushNotificationIOS.register
_ ->
Cmd.none
@ohanhi @eeue56 Thanks for giving this PR new life! I've made the suggested changes. If it looks good, let me know so I can squash and get this merged 👍
This adds an Alert module for showing system dialogs, as well as a PushNotificationIOS module for handling push notifications on.. iOS!
See Purple Train PR for complete real-world usage examples: https://github.com/thoughtbot/PurpleTrainElm/pull/71
Here are some example snippets: