3 Replies Latest reply on May 3, 2013 3:20 AM by Tahir Zamir

    Rhoconnect push on demand

    Tahir Zamir

      Hi,

       

      The rhoconnect-push demo (https://github.com/larsburgess/rhoconnect-push-demo) syncs the products model every 300 seconds or when the model is changed.

       

      If I wanted to change this behaviour such that there is no auto-sync after 300 seconds and a sync is not triggered when the model is changed then I assume that the following settings in the rhoconnect settings.yml file are needed:-

       

        :push_notify: false

        :poll_interval_default: 0

       

      This does indeed appear to switch off any auto-syncing.

       

      I then create a new record in the backend database and initiate a sync by running the following ruby script:-

       

      ping_params = {

          :user_id => 'lars',

          :sources => 'Product',

          :message => 'hello world',

          :vibrate => 2,

          :sound => 'welcome.mp3',

        }

       

        RestClient.post(

          "http://localhost:9292/rc/v1/users/ping", ping_params,

          { :content_type => :json,

            'X-RhoConnect-API-TOKEN' => 'my-rhoconnect-token'}

          )

       

      The 'hello world' message is displayed on the device however the new record does not appear to have been sent to the device.  A refresh action on the device confirms this.

       

      Interestingly, a 'ping' from the webconsole does result in the data being synchronised to the device.

       

      What is missing from the ruby script?

       

      Tahir

        • Re: Rhoconnect push on demand
          Kutir Mobility

          Hi Tahir

           

          Trying sending the params as Json as shown below

           

          ping_params = {

            :api_token => token,

            :user_id => [array_of_users],

            :sources => source_name,

            :message => 'hello world',

            :vibrate => 2000,

            :sound => 'hello.mp3'

          }

           

          RestClient.post(

            "#{server}/rc/v1/users/ping", ping_params.to_json,

            { :content_type => :json,

              'X-RhoConnect-API-TOKEN' => @api_token }

          )

          And have you created a record in model you specified in ping params?

          Hope it helps

           

          Thanks

          Dhepthi

          Kutir Mobility

          1 of 1 people found this helpful
            • Re: Rhoconnect push on demand
              Tahir Zamir

              Hi Dhepthi,

               

              My script is pretty much the same as what you suggested with the only differences being to add the to_json method to ping_params and to include the api_token in ping_params.

               

              However, this has not made a difference to the result.  I do have a new record in my model waiting to be synced.

               

              I have had a look at the ping call from the web console in fiddler but I can't see what I'm doing thats any different.  The only thing that occurs to me is that it is something to with cookies??

               

              Tahir

              • Re: Rhoconnect push on demand
                Tahir Zamir

                Doh, just spotted it, ping_params should have the user_id and sources as arrays!