I am going to embed a Youtube live event on my site. I want to be able to output the Broadcast Status. So if the event is on hold, I want to display "On Hold", if it's live, I want to display "Live", if it's over, I want to display "Event is Over", etc.
Is this possible?
This is possible with the liveBroadcasts/list endpoint.
part -> id, status
id -> The Video ID if your Live Broadcast object
HTTP GET: GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Cstatus&id={video_id}&key={YOUR_API_KEY}
The status dictionary returned might look something like this:
"status": {
"lifeCycleStatus": "complete",
"privacyStatus": "unlisted",
"recordingStatus": "recorded"
}
The value for the lifeCycleStatus is what you're looking for. This can be one of several values:
abandoned – This broadcast was never started.
complete – The broadcast is finished.
created – The broadcast has incomplete settings, so it is not ready to transition to a live or testing status, but it has been created and is otherwise valid.
live – The broadcast is active.
liveStarting – The broadcast is in the process of transitioning to live status.
ready – The broadcast settings are complete and the broadcast can transition to a live or testing status.
reclaimed – This broadcast has been reclaimed.
revoked – This broadcast was removed by an admin action.
testStarting – The broadcast is in the process of transitioning to testing status.
testing – The broadcast is only visible to the partner.
It is possible but you need to map the status depending upon the data is coming thorough your stream or not. It will all depends on how you are tracking the YouTube traffic on your webpage.
Related
So when you test streaming to an event (via the RTMP endpoint) you switch the events lifeCycleStatus to testing. When I stop streaming to the RTMP endpoint the lifeCycleStatus still remains testing.
Essentially I need the event to go from this testing state to one where I can create and bind a new live stream to the event.
An attempt to transition the broadcast status of the event to Live is met with the error that the stream status is currently inactive which makes sense.
Is it possible to transition an event in the testing state to one where I can bind a new stream to it?
So I managed to solve this issue. Just to let you know there is no way to move a LiveBroadcast from the lifeCycleStatus from TESTING to anything other than LIVE or COMPLETED.
You can however rebind a new LiveStream to a LiveBroadcast in the state of TESTING. The broadcast will have a new boundStream and the lifeCycleStatus will be CREATED 👍
We are experimenting with the Twilio video call SDK for iOS and we are able to establish a call between two users but now we would like to send events from one user to another. For example, one user would tap a button on his device and the event would be sent to the other device to display a sound or animation. Basically we are looking for a way to establish a data channel between both callers that we can use to send events, much like a websocket.
Thanks for your input! Regards,
Enrique
Twilio recently announced a State Syncronisation API which you can use to solve your problem , have a look : https://www.twilio.com/sync
For your case, you could setup up a "Map" item ( a map of event to device identity ) on Twilio sync which could be used by a device to push their events to Cloud to which any subscribed devices can get the info pushed to .
The Background Information:
I am writing an application that uses the PubNub framework to directly couple one Raspberry Pi with one iPhone, for each individual user. The Raspberry Pi uses an Arduino as a slave to gather analog data, then uses the PubNub network to publish that data to the one and only iPhone that is on the same channel. With the data that the iPhone receives, it determines (locally) if the user needs to be alerted. Then, when the user is alerted, they have the ability to adjust the current state of the Raspberry Pi by sending data (settings) back to the Pi, which will then resolve the problem that warranted a user alert.
The Problem:
When the iPhone app goes into the background, the messages sent by the Raspberry Pi that the iPhone should be receiving will no longer be caught by the application, and therefor the user is no longer notified when they need to be. The first obvious solution would be to move the logic of what warrants an alert to the Raspberry Pi itself, so that it can use Apple Push Notifications to send those alerts to the user. However, the problem with this is that I am also trying to track whether or not the Raspberry Pi connection has timed out, so that if some unexpected disconnect occurs, the user is notified of that problem as well. This logic obviously can not be on the Raspberry Pi itself, because if a disconnect occurs, then it will not be able to push the notification to the iPhone itself. Having a middle man server of sorts to monitor the state of the device would seem like a logical solution... however I do not want anything other than the iPhone and Raspberry Pi involved in the data transmission and handling, which is clearly the entire motivation behind using PubNub in the first place (within the scope of my application).
This is not a PubNub specific problem. I only cite them to paint a clearer picture. Also worth noting is that I do not want to fake a location service in order to get iOS to grant continuous background permissions. This is a lazy and sloppy solution with undesired overhead.
The Question:
How do I receive (or request) a short string every 15 to 30 seconds in the background to determine if I should throw an alert. This has to be achievable. Based on my research and reading of apple documentation, it is clear to me that many people will try to respond with "it isn't possible." I do not welcome this answer. I am here to find a solution that I could not previously find, or that has not previously been proposed. I need an intelligent engineer to propose a genuine solution or workaround to my problem.
I sincerely thank the champion engineer in advance.
#JonW I read your question, and some of the comment until I got to the TL;DR point :) The short answer is that silent push notifications might be the answer to one of your problems.The other might be PubNub Presence Webhooks. But I would agree with #Paulw11 that a server is the best practice and ultimately, PubNub BLOCKS will be your solution.
Background Processing with Apple Silent Push Notifications
To do some short background processing, you can have your RPi publish a message that includes a push notification (as I believe you are already doing). But this push msg should be a silent push notification. The docs say this:
When a silent notification arrives, iOS wakes up your app in the
background so that you can get new data from your server or do
background information processing.
... ensure there is no alert, sound, or badge payload in the aps dictionary
The full details are at the link I just provided but here is a sample message payload that you would publish on PubNub with the proper aps format.
{
"pn_apns": {
"aps": {
"content-available": 1,
"data": {
"temperature": "55",
"humidity": "42%"
}
}
},
"data": {
"info": "This is the full realtime message.",
"temperature": "55",
"humidity": "42%"
}
}
WARNING: The silent push notifications are only effective if the app is not in a kill state. In other words, it must be idle in background - not running, but idle. If you force kill the app (swipe up from recent apps list by double tap Home button) or do not start the app after device has been powered off then on again, then silent pushes will be ignored.
See this Badge Count Demo as a template for getting started. But as #Paulw11 said, regular push notifications every 30 seconds is not a good idea. You should be sending your updates to a server that can send a push notification to the iPhone app when it is necessary to take action.
Offline Notification with PubNub Presence Webhooks
Going further down the server process best practice, you can have your server monitor the presence of the RPi on the channel. If the RPi ever leaves the channel by explicit unsubscribe from channel (leave event) or by network disconnect (timeout event), then a message can be POSTed to your server REST endpoint (that you provide us to configure on your PubNub keys). If either of these events happens, then you can publish a message (silent push payload included) to your iPhone app to take appropriate action.
PubNub BLOCKS - No Server Required (Look mom, no server!)
So you say you want to avoid using a server. With PubNub BLOCKS, you will be able to avoid using your own server - instead, you will use PubNub servers.
I won't into too much details here, but you will be able to write a small bit of JavaScript in a BLOCK that can determine if a push notification needs to be sent or not and much much more.
Summary
For now, I think your prototype with silent push is good to flesh out your use case. But ultimately, you need to have an always on process that can determine when it is necessary to send a push notification. While your iPhone app is active, it can receive the realtime messages from RPi, but when in background, getting a silent push every 30 seconds is not ideal and possibly not allowed by Apple.
Im developing an iOS app that has a feature of Push notifications. Its a sports app where a user can add players to their favorites list. Each player has 3 kinds of events.
Like,
score a Goal
got a red car from referee
got a yellow car from referee
Now in this scenario,
User X has configured player A for all 3 types
User Y has configured player A for first 2 types
User Z has configured player B for last 2 types
Now Server receives an update for Player A scores a Goal(1st type).
What exactly should be the payload?
I have tried the following
{"aps": {"badge": "+1", "alert": "Player A scored a Goal 10K", "participantID":["A"],"tags":["score a Goal"]}, "aliases": ["sportEvent2013"]}
At present im broadcasting the update, that is every device configured with APNS receive the push and only the one which matches the tag and participantID is displayed.
It does work, but i think this is not appropriate like every device receive the updates which can be in thousands, (im not using device token) because i can not tell who has configured for which events?
Please help me with the right approach.
Thanks
I can give more details if you give more details about your setup (all client, server component, etc). However the general idea should be to use the 'Tags' feature by urban airship (you can use alias too.. but that's not as flexible):
UAirship Tags
The general concept is to 'subscribe' a user and their device token to a tag such as "PlayerAGoalScored". And then when that update comes through you can just tell urban airship to send a push to everyone subscribed to the tag 'PlayerAGoalscored"
You could set it up so that when a user configures a player to receive a particular type of notification, the app updates your database. Then, when the server receives an update for a player, query your database for those who have that flag set and send the notification only to them.
Within my iPhone application I periodically make calls to a webservice, providing the endpoint with a list of numeric IDs. The webservice then returns information relating to the IDs it receives.
This is all well and good. However, I would like to be able to provide functionality whereby the user will receive a local/push notification when these changes occur, regardless of whether the application is open or not.
I'm just looking for guidance on my options in this scenario. As I see it, there are two main approaches: calculate any data changes on my webserver and send a push notification to all devices, or query the webservice from the device itself.
The second option seems ideal, as not all devices will need each push notification, but I'm unsure as to whether this is possible with the current state of iOS' multitasking APIs. Any advice would be appreciated.
Bad news: it's not possible. Apps can only run in the background for a short period of time after the user has exited unless it fits into a small number of categories (GPS, VoIP, etc).
Web services, unfortunately, do not count. So this would have to be performed on the server side and with push notifications.