OneSignalPlus | Get PlayerID, Send Push, Add Tag, etc [Donation]

extension
howto

#21

This extension is an further development from the previous version.
in this version I added an addtag feature for certain users.
the advantages of using this tag feature are explained on this page.

example block

you also can delete the tags, just set the key with the tag which you want to delete and set the value with blank text.

if you need this component, you can send a little donation for further development. You can send donations to my paypal here . Donations can be of any value
send a personal message to me after you give a donation, I will send the download link via email.


#22

Hi @wanttobe,

You are doing nice work but i merged all your topics about the same extension together. This way we can keep the forum as clean as possible. I hope you understand.


#23

this is the further development from OneSignalPlus extension.
in this version, i have added the feature so you can send push notification to specific segment

if you need this component, you can send a donation for further development. You can send donations to my paypal here . Donations can be of any value
send a personal message to me after you give a donation, I will send the download link via email.


Extension OneSignalSend
#24

here is the sample block joined with Web Extension


Sending notifications using Onesignal API
#25

hola, estoy usando esta Extension y quiero comentarles que funciona perfectamente!
Uso Android 8.0

Saludos


#26

thanks a lot for your informations


#27

Hello, I made a donation, you could send me the onesignal plus extension to my email


#28

Just made a donation, can you send me the onesignal plus extension to my email, please?


#29

Send a pm to the developer as stated in his post.


#30


Please help with correct format for include_player_id. All efforts to put string values into the array from mysql database give error. I used your extension to get playerId and insert into the database. If i paste the value directly my code works.
I’m dealing with just one value of playerId, not an array.

Thank you.


#31

try put php variable into your function

<?php
    function sendMessage($playerID){
   .....
    $fileds = array(
        'app_id => "your app ID from OneSignal",
        'include_player_ids' => array($playerID)',
        ....

    );
.....
}
$playerID = "put your player ids here"; 
sendMessage($playerID);

#32

Thanks for your response.
This is what I did, fetching string from my database but onesignal sees null.
I guess I’m still doing something wrong.

// …fetch from database
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {

function sendMessage(){
$content = array("en" => $_POST['message']);
$fields = array(
'app_id' => "my app id",
'include_player_ids' => array($row["playerId"]),
'contents' => $content
);
	
	$fields = json_encode($fields);
	print("\nJSON sent:\n");
	print($fields);


#33

just apply my code above, your code was wrong anyway.


#34

I desire to push message to an individual user. I have tried your code, it didn’t work for me. Can you please show the complete code to include message to be sent. Maybe that’s where I’m getting things wrong. I hope to order the new version of your extension this week if you have alternative payment processing. I don’t have paypal account presently.
Thank you.


#35

Replying to myself. I got it done. For those who may be interested, to send onesignal push notification to a user, see the script below.:

function sendMessage(){
$content = array(“en” => $_POST[‘message’]);
$fields = array(
‘app_id’ => “your app id here”,
‘include_player_ids’ => array($_POST[‘playerId’]),
‘contents’ => $content
);

$fields = json_encode($fields);
print("\nJSON sent:\n");

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
	curl_setopt($ch, CURLOPT_HEADER, FALSE);
	curl_setopt($ch, CURLOPT_POST, TRUE);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

	$response = curl_exec($ch);
	curl_close($ch);
	
	return $response;
}
                        }                               	

$response = sendMessage();
$return[“allresponses”] = $response;
$return = json_encode( $return);
print($return);
print("\n\nJSON received:\n");

I used extension to get playerId for a user, save to mysql database and sent it to the user by email on first run of the app, Phone anti-theft and anti-abduction app. In the event that the phone is stolen, the owner may prompt phone call or use of the app by sending onesignal push notification to the device with the player ID form my website.
My discovery that I could not explain:
Getting data from the web

$message = $_POST[‘message’];
$playerId = $_POST[‘playerId’];
If substitute the string value on the left in the above script, onesignal will see null and present error but if I substitute the string value on the right, the message sends successfully.
Can someone tell me why?
For this reason, I could not get string value from the database and use directly.
$row[“playerId”] will give null error.
I have been able to add an important feature to phone app, “prompt a call”. Thanks to @wanttobe for Get Player ID.
See user’s face feature: Thanks to @Taifun camera extension.
Try it: https://play.google.com/store/apps/details?id=com.contritrack.phone


#36

What function does the TagResponse block fulfill? Is it possible to modify it so that when the receiver of the notification presses and can go to a specific window?


#37

thanks for contributing!
I am WILLing to DONATE for YOUR STUDY.
my email yoonchanglee4@gmail.com
I wish your success.


#38

@618dccc00496f8e95e68 what about sending a PM to the developer? probably posting your email address in a public forum is not a good idea, is it? do you want to attract loads of spam in your inbox?
Taifun