B4A Library Parse Library – Push Notifications and Cloud Storage

stu14t

Active Member
Licensed User
Longtime User
Hi agraham

I sent you some beer money via Paypal for your excellent libraries. I wonder if you could answer my previous question about the ParseUser object.

Thanks from the Squid!

I'd be interested to see the functionality of PaseUser or PFUser added to this library. Should I add this to the wishlist?
 

mrodriguez

Member
Licensed User
Longtime User

I have the same questions, specially 1) and 4)

1) The notification in the status bar is a must with this library? I need to receive the Information send by the push service in the background and in a silent way. My application checks the received data and decide what to do.

4) To subscribe the push service, is it a must to reference to an activity? Can it be a service also? At least the required type is class. I cannot give a try because receiving a push message the activity Notification is called and not myone. What I've done wrong?

Thanks
 

mrodriguez

Member
Licensed User
Longtime User
Hi, I have 2 questions about parse library that was posting by other member too.

a) The notification in the status bar is a must with this library? I need to receive the Information send by the push service in the background and in a silent way. My application checks the received data and decide what to do.

b) To subscribe the push service, is it a must to reference to an activity? Can it be a service also? At least the required type is class. I cannot give a try because receiving a push message the activity Notification is called and not myone.

Thanks
 

mrodriguez

Member
Licensed User
Longtime User

Derez, I'm trying to send push notification from one android device to another one. Could you do it? Can share the code?
Thanks
 

derez

Expert
Licensed User
Longtime User
send push notification from one android device to another one
what I do in my applications with parse is send notifications triggered by one user to all the users (example - update of an item in family tree).
I haven't sent from one device to only one other device, but it is possible - you have to know the user ID in parse.
 

mrodriguez

Member
Licensed User
Longtime User
\Hi,

Hi, that exactly what i need. One android device (mine) is the master, and the others android devices are the slaves (customers). Master device send notifications to slaves devices.
Have you done everything over b4a code (master device)? Can you share this part of code?
Or have you used parse java coud code to do that?

On other hand, can you send notificacion over a module service instead activity? I need to receive the information send by the push service in the background and in a silent way. Right now i can receive it with a notification and over an activity.
Thanks a lot.
 

derez

Expert
Licensed User
Longtime User
Here are some subs with the code relevant to push notification. You have also to enable push in your prject in parse site.
There is no master -slave relations, any device that sends a notification broadcasts it to all.
B4X:
Sub Process_Globals

Dim Parse As Parse
Dim push As ParsePush

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("family.bal")

'parse
If FirstTime Then
    Parse.SetLoggingLevel(2147483647)
    Parse.EnableNotifications(FamilyNotification)
    Parse.Subscribe("Family", FamilyNotification)

    push.Initialize
    push.SetChannel("Family")
    push.SetExpirationTimeInterval(300)
   End If

End Sub

Sub delete_click
    push.SetMessage(Ft.Name & " " & Ft.Surname & " deleted")
    push.Send("push",2)
End Sub

Sub parse_add_item(k As Int)
Dim Addpo As ParseObject
Addpo.Initialize("Family")
p_item_common(k , Addpo)
End Sub

Sub p_item_common(k As Int, Npo As ParseObject)
...
    push.SetMessage(cur.GetString("Name") & " " & cur.GetString("Surname") & " updated")
...
push.Send("push",2)
...
End Sub

In manifest file I have this added:
B4X:
SetManifestAttribute("android:installLocation", "auto")
SetActivityAttribute(FamilyNotification, android:noHistory, "true")
SetActivityAttribute(Main, android:screenOrientation, "landscape")
SetActivityAttribute(FamilyNotification, android:screenOrientation, "unspecified")

SetApplicationAttribute(android:name,"anywheresoftware.b4a.objects.ParseObjectWrapper$ParseApplication")

AddApplicationText(<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
  <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
    <action android:name="android.intent.action.USER_PRESENT" />
  </intent-filter>
</receiver>)

I need to receive the information send by the push service in the background and in a silent way.
The way the notification is recieved is not controlled by the application or by parse, its the way android works. Can it be changed ? I don't know.
 
Last edited:

mrodriguez

Member
Licensed User
Longtime User

Thanks a lot!!!
 

mrodriguez

Member
Licensed User
Longtime User
Hi, it seems that parse can send push notification to a service and in a silent way.

The probem is that there is no Push.setData , just Push.SetMessage.
I hope that someone can add it to the library.

Customizing your Notifications
  • alert: the notification's message.
  • action:(Android only) the Intent should be fired when the push is received. If no title or alert values are specified, the Intent will be fired but no notification will appear to the user.
FROM: https://parse.com/questions/custom-handling-of-push-notification

public void pushText(View v)
{
TextView pushTextView = (TextView)findViewById(R.id.editText1);
String textToBePushed = pushTextView.getText().toString();
Toast.makeText(getApplicationContext(), "onClick()"+v.getId(), Toast.LENGTH_LONG).show();
ParsePush push = new ParsePush();
push.setMessage(textToBePushed);
//push.setPushToAndroid(true);
push.setChannel("mySecondChannel");

JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("action", "com.example.UPDATE_SCORE");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
push.setData(jsonObject);


push.sendInBackground();
}
========================

<service android:name="com.parse.PushService"></service>
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>

<receiver android:name="com.example.mywordsapp.MyNotificationsReceiver">
<intent-filter>
<action android:name="com.example.UPDATE_SCORE" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />


</intent-filter>
</receiver>

================================= public void onReceive(Context context, Intent intent) {

Log.e(MY_NOTIFICATIONS_RECEIVER, "in onReceive()");
--
--
}

More links
http://developingonandroid.wordpres...-push-notifications-in-parse-a-deep-overview/

http://www.androidbook.com/akc/display?url=DisplayNoteIMPURL&reportId=4553&ownerUserId=android
 
Last edited:

brelto85

Active Member
Licensed User
Longtime User
With this library, is possibile to link the facebook user with this functionality using the "Linking Users" section?
 

QuentinLindh

Member
Licensed User
Longtime User
I am attempting to get the parse example up and running with the new parse1.7.0
The example compiles, installs on my device (nexus 7) but "stops working" before opening.
From the parse.com website I gather that 1.7.0 is pretty new. I wonder if anyone else is running this version of the with success?
Or Can anyone link me to an older version of the parse sdk that will work?
Thanks,
Quentin
UPDATE:
works fine, my problem was not making res.xml read only- it got deleted.
 
Last edited:

QuentinLindh

Member
Licensed User
Longtime User
Update:
actually, it seems to work fine- my problem was that I did not make the res.xml file with the keys read only and it got deleted..
 

QuentinLindh

Member
Licensed User
Longtime User
I have a very basic question: Excuse me if it is dumb/basic I am new to both parse and b4a
I want to use parse backside to do a very simple thing, save and keep synced some set-points,
let's say 10 integers.
So I create a Parse object it and I put in my setpoints e.g. params.Put("setpoint1","5") ...
I can save it to the parse database, with params.Save("params",1)
This works fine, there it is in the parse dashboard, all very nice and easy.
Here is where I am stuck: I want to do 2 things
1: I want to update the object that is stored in the database, not add a new one, with a new unique objectID -- like update in SQL
2: I want to poll the server when the app loads and get the object into memory. -- can I use params.refresh to achieve this?
It seems like overkill to do a query where I just want to put and get data into a single object with fixed ID.
Seems like the most simple possible case but I'm not seeing how to do it.
Thanks,
Quentin
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
please need some help to send push notification.
I follow your instruction, sign up in parse, create app, download SDK and rename it into ParseNative.jar, create res.xml and filled it with my appclientkey and appid and modified the androidmanifest.xml, as they mentioned here: https://parse.com/tutorials/android-push-notifications.
But, every time I start the app, it crash.
This is the log:

B4X:
LogCat connected to: 0607970a
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
ParseApplication.onCreate xml Id = 0
ParseApplication.onCreate xml Id = 2130903040
data null
data1 MYAPPLICATION ID
data2 MYAPPLICATION KEY

What do I do?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…