diff --git a/src/android/nl/xservices/plugins/Toast.java b/src/android/nl/xservices/plugins/Toast.java index 1232c7a..dc73424 100644 --- a/src/android/nl/xservices/plugins/Toast.java +++ b/src/android/nl/xservices/plugins/Toast.java @@ -52,7 +52,18 @@ public class Toast extends CordovaPlugin { mostRecentToast.cancel(); getViewGroup().setOnTouchListener(null); } - callbackContext.success(); + final JSONObject hideOptions = args.getJSONObject(0); + final String hidemessage = hideOptions.getString("message"); + final JSONObject hideData = hideOptions.has("data") ? hideOptions.getJSONObject("data") : null; + final JSONObject json = new JSONObject(); + try { + json.put("event", "hide"); + json.put("message", hidemessage); + json.put("data", hideData); + } catch (JSONException e) { + e.printStackTrace(); + } + callbackContext.success(json); return true; } else if (ACTION_SHOW_EVENT.equals(action)) { diff --git a/src/ios/Toast+UIView.m b/src/ios/Toast+UIView.m index 8b33055..18c7289 100644 --- a/src/ios/Toast+UIView.m +++ b/src/ios/Toast+UIView.m @@ -185,6 +185,15 @@ static id styling; - (void)toastTimerDidFinish:(NSTimer *)timer { [self hideToast:(UIView *)timer.userInfo]; + + // also send an event back to JS + NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:msg, @"message", @"hide", @"event", nil]; + if (data != nil) { + [dict setObject:data forKey:@"data"]; + } + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict]; + [commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; } - (void)handleToastTapped:(UITapGestureRecognizer *)recognizer {