twilio ip messaging in several browser tabs - php

I'm trying to implement Twilio ip messaging. I've got a problem - when another tab with the chat is opened, chat stops recieving any messages in original browser tab. How can be this problem handled?

This likely has to do with the fact that your endpoint_id value is the same for all the endpoints. This causes the problem that IP Messaging cannot disambiguate the endpoints (subscribed and connected) to send the message (and other) events to.
This guide describes how to generate endpoint_id values, and why it is important: https://www.twilio.com/docs/api/ip-messaging/guides/identity
An excerpt highlighting the specific area to focus on:
About Endpoint IDs
An "endpoint" in IP messaging is a unique app, device, and user
combination that can receive a message.
For example, "alice#example.com" using "SquareChat" on her iPhone is a
different message delivery destination (endpoint) than
"alice#example.com" using "SquareChat" on her Kindle Fire tablet.
The endpoint ID you generate on the server - while it can be a string
in any format you want - should integrate at least these three
dimensions.
Once your client receives an Access Token from your server, you can
initialize the Twilio IP Messaging SDK and start sending and receiving
messages.
Please note that if the same user logs in from 3 different endpoints - they should all have the same identity - but each of the endpoints should have a different endpoint_id - where the identity portion of the endpoint_id would be the same, but the other elements (application and device ids) should be different.

Related

sending fcm notification messages to multiple android devices by registration_ids parameter

I want to send notifications to multiple android devices(where same app is installed) by fcm from php server side by calling this url -
https://fcm.googleapis.com/fcm/send
I checked sending messages to device groups but my requirement is such that there will not be definite devices to which i will send messages because i am going to do it in a hourly cron job, and each time a cron job runs it will send notification messages to different different devices according to requirements. or can it be done in another way?
But i am thinking to use "registration_ids" parameter instead of "to" parameter, details of these fields here in the Downstream HTTP messages section. In this registration_ids field i will put all required device registration tokens in array. Now my question is after receiving message in android device can the message be parsed in the android app sdk codes?. i am in a bit of doubt as in this documentation there are no mentions of registration_ids parameter when sending messages to multiple android devices. Please assure me. And furthermore, will the message be sent when android app is in background?!. Please don't write one line, provide some examples if possible.
In the documentation for building requests to send to multiple devices you will find an example of passing multiple FCM tokens in a single call to the FCM API in the tokens parameter (in Node.js) or by using a HTTP batch request with multiple subrequests (in the REST API).
If you're having a hard time making this work, posting a question that shows what you tried increases the chances that someone can help making it work.
Yes, the message is sent regardless of whether the app is in the foreground, or in background. Whether the notification is actually shown depends on many more factors, many of which are outside of your control (such as the Android version, device maker/OEM, and the user settings).

Do I have any way or another service to push notification that have different message (payload) to different tokens in One http request?

My purpose: One Push Notification to iOS app, badgeNumber on device need to update based on each device's badge increment.
We knew that we can send only one message (payload) to different tokens
in iOS, We cannot update badge number even we receive remote notification when App is forced to close from background.
I want to use above method to send Different Badge Number to each device, since I get badge number for device from my DB Server.
I used FCM for iOS push notification
for Server-side, I use PHP
Some discussion(Android GCM - Send different payload to each user in registration_ids array )
said it's not possible, so is there any way or paid service?
Some said we need to send each payload to each device tokens using loop. Example, I have 1000 tokens, will APNS block my future request?
For my app's usage: around 50 push/day
Thank for your contribute.
Some notes to your comment:
You can update badge if the application is dead, but it cannot be a silent notification, if silent it will simply ignored. Using a "normal" notification with badge in payload you can, in fact update it even killed manually.
You must keep in database all the device token with user associated, and send individual notification, you can't send bulk message with different content (in this case with different badge).
No, it will not block, you can send for each one:
This is from another forum but can be used as reference:
According to the "Push Notification Troughput and Error Checking" section of this Tech Note:
https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG44
"There are no caps or batch size limits for using APNs."
"If you're seeing throughput lower than 9,000 notifications per second, your server might benefit from improved error handling logic."

How can we use Google Play Service for back-end server validation?

I was following these articles: Verifying Back-End Calls from Android Apps and Stopping Vampires using License Verification Library (from 24:57 to 25:34) to implement an In-App Purchase verification system for our Android apps.
I am a bit confused about how this works end-to-end and what we can assume about the generated token from calling GoogleAuthUtil.getToken() with the first email address found--when AccountManager returns more than one account. My questions are as follows:
Should we assume that any e-mail address used by the user to buy our
app will generate the same token (i.e., same user + app ==> same
token)?
If the answer to question 1 is no, is there a way to launch in-app
purchase for a particular account/email?
It looks like Google is picking the first e-mail address returned by
AccountManager for its in-app purchase dialog. Can we assume that
this won't be changed by the user after in-app purchase dialog is
launched? How do we find out if this changed after the in-app
purchase returns?
What should we store in our database to identify this user? Is email
address and/or token allowed? When does the token expire?
The java-client library looks very promising and powerful at first
read. But, a number of things remains confusing. Is there an article
that describes the end-to-end scenario--from an app initiating a
call to a back-end server through launching the in-app purchase
dialog, getting the result and closing with commits on the server?
What articles are the most useful for accomplishing this on Android?
The main issue we are trying to solve is to to get the full picture.
We've gotten the idea that we can avoid requiring userid/password by using the java client features and using tokens. We have registers our project (both the web app and android app on the same project) per the instructions for Google API Console. We have the php java-client for Google Play Service on our back-end server. We got our Android app to generate a token using the first email address and then call the in-app purchase dialog and handle the user response at the end of the dialog. We've got the parts. Now, we need to glue everything together. We are at the point of integrating with the back-end server. E.g., What is Redirect URi supposed to point to in our server? We've got a php url that we do http post messages to for our server app. We've included the code example for Google API client example--with client-id, secret, simple api key, etc. filled in--as an include to our php. But, what should we put in the redirect uri (we are missing a usage instruction for the example code)?
Also, we want to avoid having the e-mail used for the in-app purchase be different from what we log on our server database as the address the user used to buy our app; if the address is the correct thing to track, we want it to be the same as what was used for the purchase. This could be frustrating for our user if we make this mistake and prevent them from the features they paid for. We don't want to make this mistake and need some clarification on how Google Play Service works. If we initiated the server part of the workflow to get app Nonce / Payload / Credentials for the first e-mail address on the Android device, we would want that address to be used throughout the workflow. If the user changed this along the line, we want to be aware of this and gracefully recover. So far the articles have been helpful but incomplete. Any insight/suggestion is appreciated.

google checkout html api - get payment status without HTTPS?

When I log into my merchant account, in the Settings tab I can set the callback URL.
The problem is that, without HTTPS, the only option is to send back a serial number to the callback URL.
Callback contents:
[x] Notification Serial Number
e.g. serial-number=123-456-7
[ ] Notification as XML (Requires an HTTPS URL)
e.g. 123...
[ ] Notification as HTML (name/value pairs) (Requires an HTTPS URL)
e.g. google-order-number=123&...
So from this serial number, is it possible for my server-side script to get the status of the order?
I need to get the payment status of the order (paid or not, amount paid) & the order number sent back to my (custom) cart so that I can update my database.
(I can't get HTTPS at the moment because the person whose website it is doesn't want to get it)
I would caution you regarding your accepted answer.
continue_url is not an "auto-redirect". You are fully dependent on the user actually clicking that link instead of any other link in the page - notably, Google's own link to go the user's Wallet page where he/she has access to all his/her orders.
You are therefore risking your operations by possibly not having all the orders in your own system.
All Google Checkout orders have order statuses that you should really be aware of. You are already making an assumption in #1 that the user will actually click your continue_url link - additionally, you have also opened yourself up to the possibility that you are tracking orders that may not actually be approved by Google, or fails some monetary/risk authorization or check.
If a user does in fact click the link you provide, but Google has issues with the order, your system has "money" where it shouldn't.
The only reliable method of implementing Google Checkout API and integrating it with your systems is to follow documentation/instructions - in this case you must implement Notification API.
SSL is only required (on your end) if you opt for XML/name-value (data) notification
SSL is not required if you opt for serial number notification.
Yes, you can obtain all order data without installing/purchasing SSL cert for your server using serial number notification - which is what you describe.
XML/name-value notification is a "push" model - Google will "push" data to you. You will authenticate Google's basic auth request (which is why SSL is required).
serial number notification is "pull" model - you will "pull" data from Google (given a serial number - and that is why SSL is not required on your end - you will authenticate your pull request and send your request with SSL). Google isn't sending you any data, just a serial number. You will use this serial number to obtain data associated with it and provide authentication to Google - your request will use SSL.
You will use serial number notification with Notification History API to obtain data.
The links above should lead you to complete documentation/reference. If you have questions, comment here, or post it at Google Checkout Product Forums.
Hth....

If I register multiple Android devices in C2DM, do I receive multiple Registration IDs

Regarding C2DM, if I have a phone and another device (another phone, potentially a GoogleTV, etc) and I setup a C2DM server, will I receive two different Registration ID's that I can then use to send intents to both devices?
What seems like it may happen is this: I register one device and I receive my ID. Then I register another device and I receive a different ID which invalidates the first. Is my assumption correct?
I don't want to do a lot of development only to find out that a user's account can only have one Registration ID active at a time.
Yes, you will receive different registration IDs on each device. The Google account on the device is not used for registering with C2DM. The registration ID is used to send a notification to a particular application on a particular device.
More information about how the registration ID is constructed can be found in this thread from the android-c2dm Google group.
You need an active Google account on the device so that the transport underlying C2DM is active (the same mechanism is used by Google for Gmail and Market notifications).

Categories