-
Notifications
You must be signed in to change notification settings - Fork 74
Mediator agent InboxItemEvent #181
Comments
You can search for the Push Token from |
One more possible issue. It seems that Could anybody confirm this is the case? TIA |
@mat-work, from what I have been doing so far is as described below. It works without any issue.
|
Hello @sahil-khanna I'm sorry but I'm lost in the implementation of push notifications. Do you have a concrete example of use? a tutorial? Indeed I do not know where to place the portion of code that you have indicated above in the mediator. (I use the mediator contained in the repository: https://github.com/hyperledger/aries-mobile-agent-xamarin) Thanks in advance for your answer |
@Drilmo , You can try the below code. Replace it with this line
|
@sahil-khanna, thank you very much for your answer! Is it possible to set up 1 notification per type of event? if yes how to manage them? I'm sorry for these questions but I'm completely lost with this mediator. Thank you for your help. |
@Drilmo, I doubt this can be done. The Mediator Agent cannot read the contents of the payload as the payload is encrypted. All it knows is the source and the recipient of the payload. Hence, you can send a common message for all the events the Mediator Agent receives. |
This code works in mediator : using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Hyperledger.Aries.Contracts;
using Hyperledger.Aries.Routing;
using Hyperledger.Aries.Storage;
using Hyperledger.Aries.Agents;
using System.Net.Http;
namespace mediator
{
public class Program
{
private static HttpClient client = new HttpClient();
public static async Task Main(string[] args)
{
IHost Container = CreateHostBuilder(args).Build();
var eventAggregator = (IEventAggregator)Container.Services.GetService(typeof(IEventAggregator));
_ = eventAggregator.GetEventByType<InboxItemEvent>().Subscribe(async inboxItemEvent =>
{
// Get the device token
var walletRecordService = (IWalletRecordService)Container.Services.GetService(typeof(IWalletRecordService));
var agentProvider = (IAgentProvider)Container.Services.GetService(typeof(IAgentProvider));
var agentContext = await agentProvider.GetContextAsync();
List<DeviceInfoRecord> deviceInfoRecords = await walletRecordService.SearchAsync<DeviceInfoRecord>(
wallet: agentContext.Wallet,
query: SearchQuery.Equal(nameof(DeviceInfoRecord.InboxId), inboxItemEvent.InboxId.ToString()),
count: int.MaxValue);
if (deviceInfoRecords.Any()){
Console.WriteLine("Push Token : " + deviceInfoRecords.First().DeviceId);
Console.WriteLine("Mobile Platform : " + deviceInfoRecords.First().DeviceVendor);
// Send Push Notification.
}
});
Container.Run();
}
}
} |
Hi @sahil-khanna , Can you please guide me with this, I have some doubts:
|
@naman20sharma, below are my responses to your questions.
|
Hello,
Can someone please give some guidance on how to use InboxItemEvent to implement push notifications. Is InboxId field that identifies Edge agent? At what point i cn hook into and tie this filed to notification token?
Thank you
The text was updated successfully, but these errors were encountered: