Create failed case when push notification using FCM - firebase

I followed this guide to create push notifications. The push notification works correctly, but I am confused about the response:
As the docs said, a list of failed push notification devices will be listed in failed_registration_ids, but the response from FCM only has failedRegistrationTokens.
Because I want to create a scenario in which some devices are not working (offline or powered off), and the push notification cannot be delivered, and I was hoping that failed device tokens would be listed in failedRegistrationTokens but they are not, and it still responds to me with successCount: 3, failureCount: 0
My question is: Is there any way to create a case where push notifications fail to push to some devices and the response looks like this:
{
  "success":1,
  "failure":2,
  "failed_registration_ids":[
     "regId1",
     "regId2"
  ]
}
P.S. I tried several methods, including turning off the device, turning off the internet connection, and then removing the app. But I still can't create this case.
P.S.2. I also tried the Legacy API, but it only pushes up to 1000 device tokens per call; it will require sending push notifications several times when I want to push more than 1000 devices, but I want to complete it in a single call, like sending to a devices group or topic.
Thanks in advance.

Related

How to setup web hooks to send message to Slack when Firebase functions crash?

I need to actively receive crash notifications for firebase functions.
Is there any way to set up Slack webhooks to receive a message when Firebase Functions throw an Error, functions crash, or something like that?
I would love to receive issue messages by velocity ie: Firebase Functions crash 50 times a day.
Thank you so much.
First you have to create a log based (counter) metric that will be counting specific error occurencies and second - you create alerting policy with Slack notification channel.
Let's start from finding corresponding logs that appear when the function throws an error. Since I didn't have one that would crash I used logs that indicated that it was started.
Next you have to create a log based metric. Ignore the next screen and go to Monitoring > Alerting. Click on "Create new policy", find your metric and select "Rolling Window" to whatever time period you need. For testing I used 1 minute. Then set "Rollind windows function" to "mean".
Now configure when the alert has to be triggered - I chose over 3 (within 1 minute window).
On the next screen you select notification channel. In case of Slack it has to be configured first in "Notification Channels".
You can save policy the policy now.
After a few minutes I gathered enough data to generate two incidents:
And here's some alerting related documentation that may help you understand how to use them.

Python receive Google Drive push notification

Since the Drive SDK v3 we are able to receive push notifications from Google Drive whenever a file has changed. At the moment I'm working on a Drive application in Python and I would like to receive such notifications. Do I really need a web server for this or can I implement this maybe with a socket or something like this?
I know that I can get changes by polling the changes.list method but I want to avoid this because of so many API calls. Is there maybe a better way to get informed if a file has changed?
EDIT: I captured my web traffic and saw, that the original Google Drive Client for Windows uses push notifications. So in some way it must be possible to get push notifications in a desktop application but is this maybe some sort of Google magic which we can't use with the current API
For Google Drive apps that need to keep track of changes to files, the Changes collection provides an efficient way to detect changes to all files, including those that have been shared with a user. The collection works by providing the current state of each file, if and only if the file has changed since a given point in time.
Retrieving changes requires a pageToken to indicate a point in time to fetch changes from.
# Begin with our last saved start token for this user or the
# current token from getStartPageToken()
page_token = saved_start_page_token;
while page_token is not None:
response = drive_service.changes().list(pageToken=page_token,
fields='*',
spaces='drive').execute()
for change in response.get('changes'):
# Process change
print 'Change found for file: %s' % change.get('fileId')
if 'newStartPageToken' in response:
# Last page, save this token for the next polling interval
saved_start_page_token = response.get('newStartPageToken')
page_token = response.get('nextPageToken')

Issue with Notification and Disconnect

We are trying to upgrade existing app with your framework, other things are working fine like connection/read/write however we are facing issues with Notification/Disconnect
Can you please guide for following scenarios:-
Need call back for disconnection
Notification not working we are not able to receive any notification alert
Is there any method to check characteristics of devices, as we have different devices and some characteristics are not present in all devices, when we try to read/write non present chacraterstics on devices, it throws exception and app crashes
Code :-
connection.writeDescriptor(
Defs.SVC_AUTOMATIONIO_UUID,
Defs.CHAR_AUTOMATION_IO,
Defs.DESC_CLIENT_CHAR_CONFIGURATION_UUID,
BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
)
.subscribe(
this::onWriteSuccess,
this::onWriteFailure
);
connection.setupNotification(iCharUuid)
.flatMap(notificationObservable -> notificationObservable)
.subscribe(
this::onNotificationReceived,
this::onConnectionFailure
);
Thanks
Swayam
In general you don't have to write descriptor manually to enable notifications. The library does it for you.
Try: (example)
rxBleConnection.setupNotification(Defs.DESC_CLIENT_CHAR_CONFIGURATION_UUID)
.flatMap(notificationObservable -> notificationObservable)
.subscribe(this::onNotificationReceived, this::onNotificationSetupFailure);
In order to get callback for disconnection: (example)
You can observe onError from establishConnection method.
You can setup connection status observable
bleDevice.observeConnectionStateChanges().subscribe(this::onConnectionStateChange);
To check characteristics you can go with service discovery: (example)
bleDevice.establishConnection(this, false)
.flatMap(RxBleConnection::discoverServices)
.first() // Disconnect automatically after discovery
.subscribe(this::processDiscoveredServices, this::onConnectionFailure);

Unable to Receive Pushes in client application after Registration in BB10 Webworks

My question is similar to BlackBerry push client application subscription but still i have doubts in that ..plz clarify.My doubt is When i tried with sample Push Initiator which comes with Push SDK and Sample Push-enabled application[Push Capture] from github i can Receive Pushes in that sample application.But when i try the same logic in My own client application i am not receiving Pushes..
Steps I followed:
Registered with Push service and got Confirmation mail with AppID,Password and PPG url.
With those details i set to receive Pushes like:Called the create function and createChannel,success callback was called and it returned device token also.
But still i am not receiving Pushes in my application.Plz help where i am lagging.
Question:
How Pushes differentiate the client app and devices while sending Pushes.
NOTE:i used the same AppID which i used for sample app.
when i called create function and createChannel,success callback was called and it returned device token also. When i received Push,onInvoke event was called and action was bb.action.PUSH which denotes we received a Push..Since i didnot add Notifications to Hub i didnot recognize previously.
Also we cannot use same AppID for different applications.It will create problem

How to send push notifications to more than one platform using Redth PushSharp library?

I've been using Redth/PushSharp code to implement server side push for both Android and iPhone.
Using the following code:
foreach (Receipient in iOSUsers)
{
push.QueueNotification(NotificationFactory.Apple()
.ForDeviceToken(APNS_Device_Token_Of_Receipient)
.WithAlert("Alert!")
.WithSound("default")
.WithBadge(2));
}
foreach (Receipient in GCMUsers)
{
push.QueueNotification(NotificationFactory.AndroidGcm()
.ForDeviceRegistrationId(GCM_Device_Token_Of_Receipient)
.WithCollapseKey("NONE")
.WithJson("Alert!"));
}
My problem is that I'm able to send only to one platform at a time, the code above sends only to iPhone, and if the first loop is disabled than only Android users will get the push message.
Any clue?
I can add additional code if needed.
Thanks!
Have a look at
.WithExpiry()
to specify a expiration date for the message you sent.
I created a windows service that gets the list of ios users and android users and for each calls an instance of the pushbroker object and processes as you have above. You'll have multiple threads processing all ios and android.

Resources