Is it possible to add a custom parameter to an in-built Firebase event like in_app_purchase [duplicate] - ios

I am able to send custom parameter along with custom event to firebase analytics in android using below method :-
Bundle bundle = new Bundle();
bundle.putString("Action", "Action Perform Android");
bundle.putString("Category", "CustomEvent Android");
bundle.putString("Label", "click me");
firebaseAnalytics.logEvent("Button_clicked", bundle);
Above method is working and we can see this event on firebase console.
Here are some event that event name is reserve and we can not use this name again to send event to Firebase analytics like notification_dismiss, notification_open etc. These predefined events are automatically collected by Firebase.
Now I want to send some custom parameter along with these above event.
For example when notification_open event fired, I want to add notification title as a custom parameter along with this event. How can we override notification_open event or how can we set notification title custom parameter along with this event in android?

There is no way to add custom parameters to events that are automatically sent. You will have to define your own event to add those parameters to.
Once you've done that, you can combine the standard and custom event in BigQuery, to get both the default and the custom parameters in a single report.

Related

How to get the title and messageBody metadata from the UIActivityViewController to a custom UIActivity?

Since iOS 13 you can create a UIActivityViewController using a UIActivityItemsConfiguration. That has a perItemMetadataProvider callback that allows you to provide a title and message body. With that all setup, if you select standard activities such as Messages or Mail, the provided message body is used as the initial text message or email message. If you choose Mail, the email subject gets populated by the provided title.
I have implemented my own custom UIActivity. It appears on the activity view along with the other options. I would like to access the provided title and message body meta data within my custom UIActivity.
So far I have found that the message body gets appended to the list of items being shared. So in the calls to canPerform(withActivityItems:) and prepare(withActivityItems:) you can access the activity items along with the value set for the message body.
But so far I have not found any way to get the title. It's not added to the activity items. There's no public API for UIActivity to access this meta data. I tried adding a title (and subject) property to my custom UIActivity in hopes it would be set - it wasn't.
Does anyone have any way to get this title?
Here's the relevant portion of my code to setup and create the UIActivityViewController:
let config = UIActivityItemsConfiguration(objects: items)
config.applicationActivitiesProvider = {
return [ MyCustomActivity() ]
}
config.perItemMetadataProvider = { (index, key) in
if key == .title {
return "Some Title" // How do I get this in my activity?
} else if key == .messageBody {
// This gets added to the activity items
return NSAttributedString(string: "Some crazy message that does stuff")
} else if key == .linkPresentationMetadata {
// Used at the top of the activity view controller if set
}
return nil
}
let vc = UIActivityViewController(activityItemsConfiguration: config)
I know I could directly set a subject on my custom activity when I create it but that seems like cheating. And it might not work if using a custom activity I don't have the code for (say from a library). The point of this post is to find a "proper" way to do it using the provided APIs.
FYI - this will be the only post (as of this writing) that has UIActivityItemsConfiguration in it here on SO. Apparently it's not being used much.
Related to this is the activityViewController(_:subjectForActivityType:) method of the UIActivityItemSource protocol. This is basically an alternate way to provide the subject versus UIActivityItemsConfiguration. However, the documentation for this method states:
When posting an item the service may provide for a separate subject field and data field, such as an email message. Implement this method if you wish to provide a subject field for services that support one.
But again, there is no documented API associated with UIActivity for obtaining this subject.
Update: Using the debugger and putting a breakpoint on the line where my items configuration returns a title I discovered that the breakpoint is reached after tapping on the Mail icon in the activity view. There is a UIMailActivity that is calling a private method named _subjectForActivityItem: on UIActivity. So it seems Apple went to the trouble of adding public APIs for providing a subject but only Apple-provided activities can call the private method to access the subject. Ugh!

Firebase Database doesn't return value offline

I'm working on a app with Firebase Database and I also want to allow the user adding entries when he's offline. Imagine the following case (everything offline; it works perfectly online):
The user adds a client (shown in a main tableview - works)
On the detail view of the freshly added client, he adds an appointment with him. The appointments are listed in a tableview in the Client Detail ViewController.
When the appointment is added, the tableview isn't refreshed, because the callback doesn't call.
In code:
navCont.child = userDB.child(entityNameClients).childByAutoId()
navCont.child?.setValue(post) where post is a dictionary with the values of the customer
On the viewDidLoad Method of the detail view controller, I call the following code: getUsersDBReference().child(entityNameAppointments).child(clientKey).observe(.value). The Callback isn't called (probably because there are no elements in it)
Adding Appointment
var appointment:DatabaseReference
appointment = getUsersDBReference().child(entityNameAppointments).child(clientKey).childByAutoId()
appointment.setValue(appointmentDict)
The Callback of 2 isn't called (--> and the tableview not refreshed with the new appointment)
BTW, I set Database.database().isPersistenceEnabled = true in App Delegates applicationDidLoad-method.
And if I add the client online and go offline then, it works too.
Answer of Firebase Support:
The SDK attempts not to fire Value events with "partial" data. Since you are only updating a subnode of the location being observed, we don't have "complete" data and so the observer is not fired. If the SDK has ever had "complete" data for that node (e.g. because you overwrote the whole node or because you were previously online and got complete data for it), then it will fire events when you update it.
One workaround would be to use ChildAdded (and ChildChanged, etc.) events instead of Value.

iOS Different Actions for Different Local Notifications?

My app has two different features that can each schedule a local notification. They are both reminders, but for different things, and for different parts of the app. Is there a way to schedule 2 different actions for these? For example, clicking notification style 1 sends you to the first tab, clicking notification style 2 sends you to the 2nd tab?
Yes this is possible, just add a custom NSDictionary to the UILocalNotification userinfo property.
For example, add a type when you create the UILocalNotification:
myLocalnotification.userInfo = #{#"type" : #"openTab1"};
Then in the application:didReceiveLocalNotification: you could do:
if ([notification.userInfo[#"type"] isEqualToString:#"openTab1"]) {
// Your code to open tab1
}
UILocalNotifications supports the userInfo dictionary. You can add some information here to trigger the response you want. For instance you can create you own "action" dictionary:
#{ #"action" : #"open_tab_1"}
When you receive the notification you inspect the userInfo and check the action key and trigger the correct behavior by just checking the equality of 2 strings.

QuickBlox update custom object without using ID

I use QuickBlox for my chat app.
When updating/deleting a custom object, is it possible not to use object.ID?
For example, I use a custom field "requestor_id" and "responder_id" to identify FriendRequest Custom Object. I need to update the status of a friend request to from "pending" to "approved".
I don't want to fetch the ID first in order to update it.
Is it possible to send along a dictionary like #{"responder_id": 123, #"requestor_id":234}?
I think it's not possible. Deleting or updating take place only with object's ID.. so you need perform at last 2 actions:
fetch items
updating/deleting

Custom email notifications for "Digest" type of alert subscription

I am working on a custom email notification for a WSS 3.0 solution. I am using a custom class inheriting from IAlertNotifyHandler to generate the email. There is a great example here that shows how this is done for an Immediate alert. Here is some of the code related to the SPAlertHandlerParams, which is used to get information about the alert and the item that triggered the alert.
SPAlertHandlerParams ahp;
int id = ahp.eventData[0].itemId; //gets the itemId of the item triggering the notification.
SPListItem myItem = list.GetItembyId(id);
For immediate alerts, this works great as the item I want is always at the [0] position of the eventData object. For a digest event, I thought I could just loop through all of the items in the ahp.eventData. Two problems with this.
First, it gives me all of the events where it is sending notifications, not just the ones for me. Second the eventData[0].itemId no longer points to a valid id on the list. It is 6-7 digit number instead of a 3 digit number.
Does anyone know the correct way to get to the alert information for digest emails?
Please let me know if you have any additional questions about this.
Thanks for your help!
For my project, I created a custom timer job (using the post by Andrew Connell) that mimics the Alert functionality. It runs overnight and queries for any users subscribed to my list with daily alerts. It then packages all of the new tasks into a custom email message.
I left the custom alert in place to suppress any daily notifications from the system. I just return 'True' so that alerts are not sent for tasks assigned to only 1 person. I suppose looking back on this, I could have run the query code in the custom alert and not need a separate timer job.

Resources