Interested in sending Pushbullet Pushes with B4A?

Discussion in 'Chit Chat' started by DonManfred, Feb 11, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    Just want to know whether you are interested or not...

    Getting/reading the following Data i already have:
    - ME (info about my account)
    - Contacts (lists my contacts)
    - Subscriptions (lists my subscriptions)
    - Devices (lists my devices)

    Pushes already send is not ready actually

    I´m working on "Sending a Push to one or more devices or to a contact" actually...

    PS: I´m just using B4A, httputils and JSON
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    Hmm, sounds good but until a few minutes ago I had never even heard of Pushbullet...

    inakigarm, lemonisdead and DonManfred like this.
  3. KMatle

    KMatle Expert Licensed User

    Which technique is used to send a "push" from device a to b?
  4. DonManfred

    DonManfred Expert Licensed User

    simple httputils-calls....

    App a sends a httprequest to pushbullet-server. Pushbullet-server sends this then to app b

    As the sending of a push is not ready yet i show you an example of getting "me"
    It gets informations about your account... id, created and so on...

    Dim Const PB As String = ""
    ' Get information about the current user.
        Dim Const PBme As String = PB&"users/me"
    Dim job As HttpJob
    "Authorization""Bearer "&secret)

    Sub JobDone (job As HttpJob)
    "JobDone ("&job.JobName&")",Colors.Blue)
    If job.Success = True Then
    Select job.JobName
    Case "ME"
    Dim parser As JSONParser
    Dim root As Map = parser.NextObject
    Dim iden As String = root.Get("iden")

    Dim email As String = root.Get("email")
    Dim name As String = root.Get("name")

    Dim created As Double = root.Get("created")

    Dim google_userinfo As Map = root.Get("google_userinfo")
    Dim name As String = google_userinfo.Get("name")
    Dim email_normalized As String = root.Get("email_normalized")
    Dim preferences As Map = root.Get("preferences")

    Dim onboarding As Map = preferences.Get("onboarding")
    Dim extension As String = onboarding.Get("extension")
    Dim app As String = onboarding.Get("app")
    Dim friends As String = onboarding.Get("friends")
    Dim mac As String = onboarding.Get("mac")
    Dim modified As Double = root.Get("modified")
    Dim image_url As String = root.Get("image_url")
    Last edited: Feb 11, 2015
  5. DonManfred

    DonManfred Expert Licensed User

    it is really great...
    You can use my gmail emailadress to send a push to me if you want

    Last edited: Feb 11, 2015
    lemonisdead and Peter Simpson like this.
  6. imbault

    imbault Well-Known Member Licensed User

    Looks like sample and very interesting technique...

    Any more samples @DonManfred ?
  7. DonManfred

    DonManfred Expert Licensed User

    Actually no... I´m working on sending the pushes and on creating the sample app

    Hopefully i get all working till weekend

    If you want to help

    Target Parameters

    Each push has a target, if you don't specify a target, we will broadcast it to all of the user's devices. Only one target may be specified.

    device_iden - Send the push to a specific device. Appears as target_device_iden on the push. You can find this using the /v2/devices call.
    email - Send the push to this email address. If that email address is associated with a Pushbullet user, we will send it directly to that user, otherwise we will fallback to sending an email to the email address (this will also happen if a user exists but has no devices registered).
    channel_tag - Send the push to all subscribers to your channel that has this tag.
    client_iden - Send the push to all users who have granted access to your OAuth client that has this iden.

    But i cant find any sample which set the target to a special device or a email so i dont know how to USE the target....

    Drop me an info if anyone knows
    Last edited: Feb 12, 2015
  8. DonManfred

    DonManfred Expert Licensed User

    Sending a push without setting a target works... The pushes are send to all my devices in this case
    KMatle likes this.
  9. udg

    udg Expert Licensed User

    Hi Manfred,

    thank you very much to have driven my attention to this service. It sounds very interesting!
    I've just started reading the docs you linked, so what follows could be entirely wrong, but have a look at it anyway.

    It is my understandig that to send a note to a specific device you should call:
    Dim PBService AsString = ""
    Dim TargetDevice as string = "udm0Tdjz5A7bL4NM" ' sets the target devices's device_iden here; a list is provided by v2/devices API

    Dim job AsHttpJob
    'set header 'Content-Type: application/json
    'set data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'
    Are you coding a class/library to make use of PB? Do you plan to use it for any specific project (like an "help me" message send to all the registered/channeled devices)?

  10. DonManfred

    DonManfred Expert Licensed User

    You are missing the target too. THAT´s my problem. Where to "put" the target?
  11. udg

    udg Expert Licensed User

    My probably wrong idea is that the target_id should immediately follow the word "pushes" in the URL submitted to
    I've just signed for the service so I may experiment a bit myself too, now.
  12. DonManfred

    DonManfred Expert Licensed User

    I will send you my b4a source i have so far in the meal break in a hour...
  13. DonManfred

    DonManfred Expert Licensed User

    here you go

    Attached Files:

  14. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Its a param so put:
  15. DonManfred

    DonManfred Expert Licensed User

    I dont know whether i should make a class or lib...actually it is only just simple b4a code using httputils...

    I dont have a specific project in mind. I found Pushbullet a week ago and find it VERY useful (for MY use) so i decided to write code to manage the pushes or devices... As i´m not limited to a specific project I´m open for all possibilities.
  16. DonManfred

    DonManfred Expert Licensed User

    thanx for you answer... I´ll try to use this in the post-json-payload (not using get-parameter as you suggested)

    I thought kind of the same but i did not had the time to test this actually.

    without setting a target (and this works here) the request looks like this

    Sub Button1_Click
    Dim json As JSONGenerator
    '--data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'
        json.Initialize(CreateMap("type""note""title": subject.Text, "body": body.Text))
    Dim job As HttpJob
    "Authorization""Bearer "&Main.secret)
    End Sub
    The push will be send to all my devices
  17. udg

    udg Expert Licensed User

    Hi all,

    please find attached a working example of sending a note to a single device ..well, at least I hope so, since I have only one device :D


    ps: insert your secret key in the process global var named secretkey

    Edit: post #16 and #17 almost at the same microsecond.. eheh

    Attached Files:

    DonManfred likes this.
  18. DonManfred

    DonManfred Expert Licensed User

    When it works for you then the use of the device_iden is correct. Great! This will help me :cool:

    But your code will work only for the LAST device listed in the result of devices... there is a foreach loop and you are using the last iden set in this loop...

    Thank you for your investigation!
  19. udg

    udg Expert Licensed User

    Hi Manfred,

    that was intentional since it was my first test and I didn't register any other device.
    My goal was just to have something working as a starting point to further investigation.
    I am attracted by Channels (setting one and then having a few friends to send notes to).

    BTW, do you know if all this PB world is free?
  20. DonManfred

    DonManfred Expert Licensed User

    I did not see any pro account. I also did not get any mail offering me a pro account or so.

    Honestly: I dont know

    If you dont set a target then you will get pushed to all your devices.
    So i dont know whether the parameter is accepted or not as target.
    I´ll do my own investigations on it today for sure... I´ll inform you if i find out something :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice