Comments (23)
Any guidance on this thread? I am also in the same boat as @alionthego and would appreciate guidance from this group.
from aws-mobile-appsync-sdk-ios.
Hello @alionthego
Currently, the best solution would be to attach a resolver with None data source and connect to a lambda and use it to publish notifications using AWS Pinpoint.
Unfortunately, I do not have an example on how to do this, but I will discuss with the team if we can document this use-case. I will keep this thread updated with details.
Thanks,
Rohan
from aws-mobile-appsync-sdk-ios.
The best approach I've found involves using Amplify. Amplify encompasses Appsync + ties in a lot of other helpful utilities and services. You'll want to go through the Amplify setup to create an app with analytics & notifications. I also have Auth and Storage being handled by Amplify. https://aws-amplify.github.io/docs/js/start?platform=react-native
If you choose to use Amplify, then here is the path I took for setting up automatic push notifications:
- Update the your pinpoint endpoint so you can target based on userId. We can update the analytics endpoint when a user logs in with the new token & their user id. This will allow us to follow them from device to device with notifications.
Analytics.updateEndpoint({
address: notificationToken, // The unique identifier for the recipient. use device token
optOut: 'NONE',
userId: userId
})
-
try to send a notification using the users id: https://stackoverflow.com/questions/55188010/send-push-notifications-via-aws-pinpoint-to-specified-user
-
Create a lambda function to trigger pinpoint notifications
https://stackoverflow.com/questions/45274726/send-a-notification-by-lambda-function-with-aws-pinpoint -
Now you can use a lambda resolver in appsync or a dynamodb stream to trigger the lambda function and send notifications. I used both.
Let me know if anything is unclear.
from aws-mobile-appsync-sdk-ios.
Can we receive a basic tutorial asap? I'm at the end of my project and this is one of the last things to implement
from aws-mobile-appsync-sdk-ios.
I think your idea for how to implement it is correct. I also have a chat component in my application and use an Appsync subscription to see new messages. I was not able to find any examples when I looked a few months ago.
I backlogged the task to do what you are trying to do. I don't mind letting the system send out a push notification to a user who is currently using the app. If you weigh the pros and cons it is not clear which approach is better.
- Users are offline 99% of the time so it is usually the right decision to send a push notification
- It will cost resources to run some logical check on dynamodb to know if a user is online or offline
- It will cost developer time to implement the user activity check
- it doesn't effect the user experience to send them a push when they are online
Maybe it is different for your situation but for the amount of work it wasn't worth it for me at this point.
from aws-mobile-appsync-sdk-ios.
Thank you. That's the last piece I need to have my app up and running with an appsync backend.
from aws-mobile-appsync-sdk-ios.
Hi may I ask in this thread about push notification too?
I'm implementing a chat app using Appsync. How can I detect whether a user is connected to avoid sending a push notification to him if he's online?
from aws-mobile-appsync-sdk-ios.
Hi @rohandubal , sorry I don't quite understand what u mentioned about we can 'attach a resolver with None data source and connect to a lambda and use it to publish notifications using AWS Pinpoint'. But How to invoke a lambda function from a none datasource? I only know how to invoke lambda function by using a lambda datasource
from aws-mobile-appsync-sdk-ios.
@rohandubal Was an example ever created as you described?
from aws-mobile-appsync-sdk-ios.
@btn52396 I ended up starting a fresh amplify project and dropping my previous appsync project into it.
I outline my steps to add notifications at the bottom of this comment: aws-amplify/amplify-js#1415 (comment)
Android notifications still aren't working so if you run into similar issues and figure it out can you let me know? Also, If you find a more comprehensive example could you link it?
from aws-mobile-appsync-sdk-ios.
Sending this to @nikhil-dabhade to see if this is something we should add to the tutorial docs.
from aws-mobile-appsync-sdk-ios.
It would be greatly helpful as I'm actively waiting on a tutorial as I'm not sure what the proper way to do this and need to have this feature before I launch
from aws-mobile-appsync-sdk-ios.
Recategorizing this as a documentation feature request for @nikhil-dabhade.
from aws-mobile-appsync-sdk-ios.
Can we use push sync along with app sync to send the push notification?
from aws-mobile-appsync-sdk-ios.
@bernhardt1 - This is exactly what I did. Didn’t realize to update this thread with it but thanks for documenting it
from aws-mobile-appsync-sdk-ios.
Hi, is it possible to use push notifications only when user's app is in the background or inactive. Do not want to take a dependency on lambda and pinpoint when app is active (foreground)
from aws-mobile-appsync-sdk-ios.
Yes, it is definitely possible but it isn't plug and play.
You would need to keep track of when your users are active. You should find some tutorials or guidance on how to do this if you Google it.
If you have an accurate record of user activity then you can check against it before sending out push notifications.
from aws-mobile-appsync-sdk-ios.
@bernhardt1
Thank you. I have the code to identify when app goes in the foreground and background. I have a chat app that works with appsync subscription. Assuming i store the foreground/background information in DynamoDB, i am trying to see if if i can continue to use appsync subscription (MQTT - without lambda and push notifications) when value is 'foreground' and lambda+push notifications only when value is 'not foreground' (may be using pipeline resolvers).
Please let me know if this is doable and if there are any examples, i tried looking online
from aws-mobile-appsync-sdk-ios.
Thanks @bernhardt1
from aws-mobile-appsync-sdk-ios.
Can you tell us how you implement step 4 with lambda resolver?
Question for others;
Also is there an example where I can subscribe to appsync from lambda? This is not the lambda resolver. Sooner sort of persistent lambda with express that listens to appsync subscription.
from aws-mobile-appsync-sdk-ios.
@daghanacay my resolver is simple
request
#**
The value of 'payload' after the template has been evaluated
will be passed as the event to AWS Lambda.
*#
{
"version" : "2017-02-28",
"operation": "Invoke",
"payload": $util.toJson($context.source)
}
result
#**
Could return 0 to indicate the notification failed here
*#
$util.toJson(1)
I created a type in my schema with an extra field to hold the notification resolver which calls lambda. something like this:
type ChainNotification {
id: ID
...
notification: Int
}
then you attach the resolver to notification.
...
It's a bit strange to explain if you aren't familiar with chaining resolvers. In my case:
- mutation comes in to add a chat
- The Chat data type has ChainNotification as a field
- That ChainNotification field gets the context of the mutation when you attach a resolver to it.
Hope this helps.
from aws-mobile-appsync-sdk-ios.
from aws-mobile-appsync-sdk-ios.
Thank you for opening this issue. AWS AppSync SDK for iOS entered maintenance mode in September 2023 and will receive no further updates as of September 2024.
Please use Amplify Swift going forward. For information on upgrading to Amplify Swift, refer to the Upgrade from AppSync SDK documentation.
from aws-mobile-appsync-sdk-ios.
Related Issues (20)
- Crash: AWSAppSyncClient.sync HOT 5
- Removing pods from source control HOT 2
- AWSMobileClient Crash when app starts HOT 3
- Completion Handler on AWSAppSyncClient.perform called more than once. HOT 1
- Enabling retry for custom scenarios HOT 1
- Update SQLite dependency to match Amplify.DataStore's SQLite version
- Make public constructor for GraphQLError HOT 2
- SPM dependency conflict with Amplify library HOT 6
- Using AWSAppSync with Amplify DataStore HOT 5
- App crashes: AWSAppSync $s10AWSAppSync36AWSCognitoUserPoolsAuthProviderAsyncPAAE09getLatestF5TokenSSyF HOT 1
- SPM dependency resolution failure using aws-mobile-appsync-sdk-ios 3.6.2 and amplify-swift 2.6.0 HOT 2
- AWS subscriptions - subscribe function is not thread safe and causes crashes HOT 1
- Version incompability with other amplify packages HOT 2
- Unknow TCP connection process keep running even when all subscriptions are unsubscribed HOT 1
- How to avoid duplicate mutations when the app is backgrounded/quit before the mutation is finished? HOT 1
- AppSync retry mechanism HOT 3
- Built app with Xcode 15.2 crashes after AppSyncClient subscribe on iOS 16.3.1 version or lower HOT 4
- For iOS App, We are using this SDK, We are getting ITMS-91053: Missing API declaration recently because PrivacyInfo needs to be included for 3rd party SDK. HOT 9
- Crash on APIKeyBasedConnectionPool HOT 12
- Xcode 16 build error "Missing argument label 'value'" HOT 1
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 aws-mobile-appsync-sdk-ios.