pusher / push-notifications-ruby

Pusher Beams Ruby Server SDK
https://www.pusher.com/beams
MIT License
18 stars 9 forks source link

Decide in content-available should be enabled or not? #8

Closed emilkarl closed 5 years ago

emilkarl commented 6 years ago

How is content-available implemented. It seems like it is always set to 1 for us. And I cannot see how I can set this myself.

We have background notifications enabled but dont want all of them to trigger this. We would like to be able to send custom data that we can use to navigate the user when the notification is clicked.

I'm just pushing some data with:

data = {
      apns: {
        aps: {
          alert: {
            title: "foo",
            body: "bar",
          },
          data: {
            goto: "User",
            id: 1,
          },
          sound: "default",
        },
      },
    }

Pusher::PushNotifications.publish(interests: interests, payload: data)
emilkarl commented 6 years ago

@ewal? :)

jonathanlloyd commented 6 years ago

Hi! We set content-available to 1 so that we can track the notification when it arrives. If you want to ignore these tracking notifications in your code you can use the remoteNotificationType: https://docs.pusher.com/beams/reference/ios#handle-notification

Does this solve your issue?

emilkarl commented 6 years ago

@jonathanlloyd I can see userShouldIgnore = 1; in the notification... but that is also set if I click on the notification. So basically if the app is open and I get a notification, this is set. I the app is closed or in the background and I click on the notification in my code... userShouldIgnore = 1; is also set.

lukabratos commented 5 years ago

@emilkarl we have updated the docs and explain in details when the status is .ShouldProcess or .ShouldIgnore: https://docs.pusher.com/beams/reference/ios#-handlenotification

Let me know if this issue is still relevant or if you have any other questions.

Thanks!

LinusGeffarth commented 4 years ago

For me, I see content-available: 1 (which I did not set) and userShouldIgnore: 1, even though the docs (at your link) say:

Case Status
Whenever content-available: 1 is set. .shouldProcess

I do get a .shouldIgnore anyway.


This is how I create my push notifications in the backend (PHP):

$this->beamsClient->publishToUsers(
    $userIDs,
    array(
        "apns" => array("aps" => array(
            "alert" => array(
                "title" => "Hello, world!",
                "body" => "This is my first push notification!."
            )
        )
    )
));

...which yields this payload (as inspected from userInfo in AppDelegate's didReceiveRemoteNotification:

{
  "aps" : {
    "content-available" : 1,
    "alert" : {
      "title" : "Hello, world!",
      "body" : "This is my first push notification!."
    }
  },
  "data" : {
    "pusher" : {
      "instanceId" : "<redacted>",
      "userShouldIgnore" : true,
      "publishId" : "<redacted>"
    }
  }
}
musthavesteve commented 4 years ago

I'm experiencing the same problem as @LinusGeffarth - anyone have any thoughts?