Comments (5)
Hello,
Congratulations on integrating Google Wallet into your application :)
There are two main properties that must be set in a pass object to enable upcoming notifications:
genericobject.notifications
genericobject.validTimeInterval
There are a couple important things to consider when setting these:
- This is configured on the pass object, not on the pass class.
- Make sure to specify the fully-qualified class for any
Google.Apis.Walletobjects.v1.Data.DateTime
fields (so they aren't confused withSystem.DateTime
). - In the
notifications
configuration,expiryNotification
takes precedence overupcomingNotification
. If you plan to setexpiryNotification
, settingupcomingNotification
will have no effect. - The
start
property ofvalidTimeInterval
must be set forupcomingNotification
to work. - Including an offset in the value of the
start
property will make it a specific time across the entire world. If you do not include an offset, the time will be for the local time zone the pass holder is in.
I've included a basic generic pass object definition below that includes the needed settings. Please give it a try and let me know if you run into any trouble!
GenericObject genericObject = new GenericObject
{
Id = $"{issuerId}.{objectSuffix}",
ClassId = $"{issuerId}.{classSuffix}",
CardTitle = new LocalizedString
{
DefaultValue = new TranslatedString
{
Language = "en-US",
Value = "Demo GenericObject Notifications"
}
},
Header = new LocalizedString
{
DefaultValue = new TranslatedString
{
Language = "en-US",
Value = "DboukAli98"
}
},
Notifications = new Notifications
{
UpcomingNotification = new UpcomingNotification
{
EnableNotification = true
}
},
ValidTimeInterval = new TimeInterval
{
Start = new Google.Apis.Walletobjects.v1.Data.DateTime
{
Date = "2022-11-15T10:30:00.00"
}
}
};
from rest-samples.
Thank you very much @ncalteen !
One last question what is the AddMessage property in Loyalty Pass ? I'll be glad to know more , because the official documentation is really ambiguous .
Thanks once again for your help,
from rest-samples.
And another thing can upcoming notifications be customized or they are not customizable?
from rest-samples.
Edit: Sorry, I dropped in huge images in my initial reply...
I'm happy to help! :)
The AddMessage
method lets you add text data to pass details. You can add messages either to classes or objects. Adding a message to a class will affect all pass holders, while adding a message to an object affects only the user(s) who have that specific object in their wallet.
When you add a message to a pass, it appears in the pass details section. I made a very simple example below. In this case, I have a loyalty card for my coffee shop (if only I could fit one in my office...) and want to let users know I have a new mocha available. I can add this message so it will appear in my pass details.
From the user's point of view, they will first open their pass in Google Wallet:
Next, they will select Details and see the new message I added.
The code to do this for a pass object is below. I'd recommend including an ID in the message so that they can be managed more easily, and making sure that the ID is not one that would likely be duplicated later (if this is something you plan to do).
AddMessageRequest request = new AddMessageRequest
{
Message = new Message
{
Id = "2022-11-15_MochaAnnouncement",
Body = "Try our new Mocha today!"
}
};
Stream responseStream = DemoLoyalty.service.Loyaltyobject
.Addmessage(request, $"{issuerId}.{objectSuffix}")
.ExecuteAsStream();
StreamReader responseReader = new StreamReader(responseStream);
JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());
Console.WriteLine("Message insert response");
Console.WriteLine(jsonResponse.ToString());
To answer your second question, notification text can't be customized currently. The specific text will always be:
- Upcoming notification:
genericObject.cardTitle is available now
- Expiry notification:
genericObject.cardTitle expires in [x] days
from rest-samples.
Thanks very much @ncalteen you really cleared the path!
from rest-samples.
Related Issues (20)
- Problem with generate google passes using .Net C# HOT 2
- @miguelRedit I'm also looking for a way to create a google generic pass using C#, but no results have been found. Have to got anything? Please let me know
- Grateful
- I want Google wallet accessible in Nigeria HOT 1
- Google Wallet Generic Pass Removing Card Title and Custom Font Color HOT 1
- mubashrfrn.md
- Ali AlAli
- https://aljbore.co.uk/
- Getting permission denied while creating passClass HOT 1
- GITHUB_TOKEN Permissions Actions: write Checks: write Contents: write Deployments: write Discussions: write Issues: write Metadata: read Packages: write Pages: write PullRequests: write RepositoryProjects: write SecurityEvents: write Statuses: write Secret source: Actions Prepare workflow directory Prepare all required actions Getting action download info Download action repository 'actions/checkout@v4' (SHA:b4ffde65f46336ab88eb53be808477a3936bae11) Download action repository 'actions/setup-python@v4' (SHA:65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236) Complete job name: update-date
- 0xbB297d8E8bE2D24FC54B2Ef834D9FbE2c373e064
- 18ga7JY5DeQrGxms1k6k4Qh2DDX43ntiZU HOT 3
- Barcode type must be set error since update HOT 1
- PHP example with ServiceAccountCredentials class vs keyFilePath HOT 8
- Google service "Walletobjects" does not exist or was removed previously HOT 2
- It my HOT 1
- Gw
- how does the google wallet UI handle the hairline (black in first frame, white in second frame) ?
- CallbackOptions verify in Php/Laravel
- Generic pass not having an issuer id
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest-samples.