java - Codename One send & display push notifications -
i'm trying find out how push proper notifications using codename 1 servers. i'd send notifications localnotifications - title, body, badge etc.
however in documentation push servers there seems one field concerning notification payload:
- body - body of message.
q1: how push(server side through codename 1 server) , display(codename 1 app) notification title , body server?
i'd able send , receive custom data in payload too, e.g. reference app content should opened in app when opening app "from" particular push notification.
q2: can send notification body, own json?
in codename 1 api there callback interface pushcallback, method void push(string value). callback intended purpose of "pre-processing/parsing" of notification payload before displaying localnotification?
thanks.
there various types of push messages can send in codename one, namely 0,1,2,3,4,5,100, , 101.
if require title , body, set push type 4 , separate title , body ; in payload.
if require push hidden content can use manipulate app in background, go push type 3. separate visible , hidden payloads ;. hidden section put json string, ensure vissible message doesn't start { or [. php payload example this:
$vissiblemsg = "cum ut quia delectus libero hic."; $jsonstring = json_encode(array("action" => "openmainform", "id" => "1", "message" => $vissiblemsg)); $payload = $vissiblemsg . ";" . $jsonstring; and in push(string value), read hidden json content this:
@override public void push(string value) { display.getinstance().callserially(() -> { if (value.startswith("{") || value.startswith("[")) { try { jsonobject response = new jsonobject(value); switch (response.getstring("action")) { case "openmainform": //do whatever want here break; default: //perform default action here break; } } catch (jsonexception err) { log.e(err); } } }); } if require hidden content , visible content title , body, have send push twice using type 2 , type 4 respectively, based on link shared above.
Comments
Post a Comment