Is it possible to send images using push notifications?
Posted by on 13 January 2014 02:14 PM

Is it possible to send images using push notifications?


Yes, you can send images with help of push notifications.

This can be implemented by uploading files into the Content Module and sending link to file in push notifications. User will be able to download file by link.

The following examples show how this can be done in iOS and Android.


- Upload image

NSData *file = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"YellowStar" ofType:@"png"]];
[QBContent TUploadFile:file fileName:@"Great Image" contentType:@"image/png" isPublic:YES delegate:self];

- Process the result and send push notification

- (void)completedWithResult:(Result *)result{

    // success result
    if(result.success && [result isKindOfClass:QBCFileUploadTaskResult.class]){
        QBCFileUploadTaskResult *res = (QBCFileUploadTaskResult *)result;
        int uploadedFileId = res.uploadedBlob;

        // Send push with file ID
        NSString *mesage = @"Hello man!";

        NSMutableDictionary *payload = [NSMutableDictionary dictionary];
        NSMutableDictionary *aps = [NSMutableDictionary dictionary];
        [aps setObject:@"default" forKey:QBMPushMessageSoundKey];
        [aps setObject:mesage forKey:QBMPushMessageAlertKey];
        [aps setObject:@uploadedFileId forKey:@"file_id"]; // this is file ID
        [payload setObject:aps forKey:QBMPushMessageApsKey];

        QBMPushMessage *message = [[QBMPushMessage alloc] initWithPayload:payload];

        [QBMessages TSendPush:message toUsers:@"45288" delegate:self];


- Upload image to Content module

    QBContent.uploadFileTask(photoLocationName, true, new QBCallback {    

        public void onComplete(Result result) {
            if (result.isSuccess()) {
                QBFileUploadTaskResult qbFileUploadTaskResult = (QBFileUploadTaskResult) result;
                String photoUid = "http://" + qbFileUploadTaskResult.getFile().getUid() + ".com";

            } else {

        public void onComplete(Result result, Object context) {


- send Push with image link

private static void sendPush(String photoLink, Integer... userIds) {
    QBEvent qbEvent = new QBEvent();
    StringifyArrayList<Integer> friendIds = new StringifyArrayList<Integer>(Arrays.asList(userIds));
    HashMap<String, String> message = new HashMap<String, String>();
    message.put("photoLink", photoLink);
    QBMessages.createEvent(qbEvent, sendPushNotificationCallback);


Comments (0)
Post a new comment
Full Name: