Reputation: 452
I am looking to display incoming push notifications in a table view within my app. I am using the parse framework for push notifications which are triggered via scripts within an existing CRM product. I have setup separate channels for each user for advanced targeting purposes.
What i am looking to do is display all push notifications for the specific user based on their channel in a table view. I would also like to have a way for the user to delete the notification from their phone but not from the parse backend. I'm pretty sure this could be done with a query and a custom field in parse to show a message as deleted by user. The query would look at the channel and then the custom field to only display messages not marked as deleted.
My question is how to structure the query and where/how to add this custom field?
Upvotes: 0
Views: 300
Reputation: 452
I have found a solution that works.
Trying to capture from an incoming push notification seems like it would only work once the application is opened and would cause delays in displaying in the table view. Trying to capture and store the data received from the push notification requires a call to parse in order to save it as an object in my custom class. I found it easier to make a call to the Rest API to create a row in a custom class in parse.
So basically when a push is triggered to an individual user the following happens.
Creates an API call to post data to parse in my custom class with all the info contained in the Push Notification plus other details like the user receiving it and info for reporting purposes.
Then the push notification is triggered after the object is created in my custom class.
Finally I have the table view querying the custom class to find the push items that are specific to the user and displays them in the table view.
So far this has worked wonderful and seems to be the easiest way to accomplish what I was looking to do.
Upvotes: 1
Reputation: 22701
Since push are tied to Installations (not users) I might suggest that you add column to the Installation table (as a collection) to a custom object you create to represent each push.
You could capture the push notifications locally and store them on the device, but I think that might only work for pushes received while the app is in foreground. The app would not have access to pushes received while in background mode unless the user performs an action on the notification.
It a shame, since I know this data is already being capture somewhere in Parse, but it does not seem to be exposed through their current API. I hate having to store this data again, but I see no other alternative.
Upvotes: 0