parse-community / parse-embedded-sdks

The Embedded SDKs for the Parse Platform
http://parseplatform.org
Other
246 stars 118 forks source link

Push Notification does not work well in Yun sdk 1.0.1-rc2 #32

Closed KoichiOno closed 9 years ago

KoichiOno commented 9 years ago

Yun SDK QuickStart guide's Push Notification source:

if (Parse.pushAvailable()) {
    ParsePush push = Parse.nextPush();
    String message = push.getJSONBody();
    . . . .
    . . . .
    // NOTE: ensure to close current push message
    // otherwise next push won't be available
    push.close();
}

1.0.0 work well. But 1.0.1-rc2 get the first notification but does not the second. Parse.nextPush() work wrong? Or the coding method has been changed in 1.0.1?

mtl2034 commented 9 years ago

Hi, we had a small change between 1.0.0 and 1.0.1-rc2 where we now ignore pushes that were already delivered to the device. We do it by storing timestamp from the last received push. Would this describe what you see? Here is the change if you want to look closer: https://github.com/ParsePlatform/parse-embedded-sdks/commit/f2e4691715e0674e4a6c304b40fa1324d465aff4

KoichiOno commented 9 years ago

Thanks for your reply. But I couldn't figure out the point. 1.0.1 client did not get new (the next) notification. 1.0.1 client get the first notification after reboot but did not get the notifications pushed after that. How client sketch should be. The quickstart example of getting push notifications will be changed?

mtl2034 commented 9 years ago

The quickstart example should not change. I will take a look on what changed? Did you update the ipks on the openwrt side to match the version from https://github.com/ParsePlatform/parse-embedded-sdks/tree/1.0.1-rc2/yun/linux_package ?

KoichiOno commented 9 years ago

Yes, I had changed Linino side ipks to 1.0.1-rc2-1_ar71xx but that did not make things better. This is my push coding in Cloud Code. This has mistakes?

var target_device = 'MY_DEVICE_INSTLLATION_ID';

//Set push target to the specific device
var query = new Parse.Query(Parse.Installation);
query.equalTo("installationId", target_device);

//Sending Push Nofitication
Parse.Push.send({
  where: query,
  data: {
    id: objId,
    act: 'on'
  }
}, {
      success: function() {
      ...
mtl2034 commented 9 years ago

Can you try to send it using curl? Here is an example:

curl -X POST \
    -H "X-Parse-Application-Id: YOUR_APP_ID" \
    -H "X-Parse-REST-API-Key: YOUR_REST_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{
          \"where\": {
            \"deviceType\": \"embedded\"
          },
          \"data\": {\"string\": \"hello\"}
        }" \
    https://api.parse.com/1/push
mtl2034 commented 9 years ago

Can you go to https://github.com/ParsePlatform/parse-embedded-sdks/tree/1.0.1-rc2 and click on 'Download ZIP' button on the right side. This way library and linux side binaries will match.

KoichiOno commented 9 years ago

The modules at https://github.com/ParsePlatform/parse-embedded-sdks/tree/1.0.1-rc2 worked well. I think that my yun's library and linux side binaries did not match. I'm going to close this issue. Thank you for your kind help.