ConnectSDK / Connect-SDK-iOS

iOS source project for Connect SDK
Apache License 2.0
175 stars 139 forks source link

sending a toast with image #188

Closed avenantsoftware closed 9 years ago

avenantsoftware commented 9 years ago

how can you send a toast message including an icon image?

this part:

the iconData string, can this be from an external URL source?

or do the images need to be located on the TV's internal storage?

and the iconExtension string is for setting the image extension like: "png" or ".png" or "PNG"?

what is the correct way?

and what image extensions are supported? png? jpg? gif?

I tried a lot of options but non work...

iadnan commented 9 years ago

the iconData string is base64 encoded string. You need to convert the image into base64 encoded string and send it witht he showToast API.

You can use the following code to convert UIImage to base 64.

avenantsoftware commented 9 years ago

but how does it work?

the image url is converted to a base64 string?

and the tv loads to image from the url

or the whole image is converted to a base64 string?

and the binary of the image is send to the tv in base64 format?

for example here you can convert images to base64:

http://www.askapache.com/online-tools/base64-image-converter/

what is send to the TV to display a message with icon is:

trough websocket is: {"type":"request","id":1,"uri":"ssap://system.notifications/createToast","payload":{"message":"Hello", "iconData": "what goes here" , "iconExtension": "png"}}

and how does the iconData string look like?

what is the correct parameter for iconExtension as I asked before? is it "png", ".png" is it case sensitive? or does it need to be something else?

The reason I'm asking is I use node to send the messages, and found in this sdk that you can also send an image with a message

avenantsoftware commented 9 years ago

nevermind found out how it works

iadnan commented 9 years ago

@spambus it is not the image url but the image converted to base64 string and is set to "iconData". I have already provided the method to convert a UIImage to base 64 string.

For sample please check https://github.com/ConnectSDK/Connect-SDK-iOS-API-Sampler (https://github.com/ConnectSDK/Connect-SDK-iOS-API-Sampler/blob/master/ConnectSDKSampler/Content/AppsViewController.m)

iadnan commented 9 years ago

@spambus thats great

avenantsoftware commented 9 years ago

Thanx