Jawbone/UPPlatform_iOS_SDK

How to implement the disconnection from my application from Jawbone UP?

Closed this issue · 0 comments

In order to see my application in the Jawbone UP application feed I have to implement the two-way disconnection mechanism to notify Jawbone when a user disconnects from my app and to receive notifications when a user disconnects from the UP app (http://jawbone.com/up/developer/disconnection):

  1. User disconnects via your application: Make the OAuth call below to notify Jawbone. The access token used for the call will be invalidated. A Pub Sub notification will be sent to verify that the disconnection notice has been received.
  2. User disconnects from Jawbone: Jawbone will notify you via Pub Sub notification as detailed under our Pub Sub section.

I had implemented the first step like that :

                 // disconnect 
                 UPURLRequest *request = [UPURLRequest deleteRequestWithEndpoint:@"/nudge/api/users/@me/PartnerAppMembership" params:nil];

                 [[UPPlatform sharedPlatform] sendRequest:request
                                               completion:^(UPURLRequest *request, UPURLResponse *response,                  NSError *error) {
                                                   // The resulting response.data is an NSDictionary with the JSON results.
                                               }];
                 // log out
                  [UPPlatform sharedPlatform].enableNetworkLogging = NO;
                  [[UPPlatform sharedPlatform] endCurrentSession];

For the second step I think I need some service in my side ( some url). I have to put in the description of my application at http://jawbone.com/up/developer/apps/. Then I have to make some requests with :

         NSString *myURL = @"myUrl.com/userId&sessionToken";
         NSString *requestString = [NSString stringWithFormat:@"/nudge/api/v.1.1/users/@me/pubsub?webhook=%@", myURL];

         UPURLRequest *request = [UPURLRequest postRequestWithEndpoint:requestString
         params:nil];

         [[UPPlatform sharedPlatform] sendRequest:request
         completion:^(UPURLRequest *request, UPURLResponse *response, NSError *error) {
         // The resulting response.data is an NSDictionary with the JSON results.
         }];

After that every time the UP user disconnects from my application, my service with myURL will receive some webhook notification. After that my service will send me notification or will invalidate the user token.

Is this the right way that I have to implement. And can you help me with some piece of code? I looked at the example projects but there is no implementation of what I need.