GithubHelp home page GithubHelp logo

Comments (23)

rohit3d2003 avatar rohit3d2003 commented on September 18, 2024 6

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.

rohandubal avatar rohandubal commented on September 18, 2024 3

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.

bernhardt1 avatar bernhardt1 commented on September 18, 2024 3

@rohit3d2003 @btn52396

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:

  1. 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
      })
  1. try to send a notification using the users id: https://stackoverflow.com/questions/55188010/send-push-notifications-via-aws-pinpoint-to-specified-user

  2. Create a lambda function to trigger pinpoint notifications
    https://stackoverflow.com/questions/45274726/send-a-notification-by-lambda-function-with-aws-pinpoint

  3. 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.

btn52396 avatar btn52396 commented on September 18, 2024 2

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.

bernhardt1 avatar bernhardt1 commented on September 18, 2024 2

@Swaroop-Bhupathiraju

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.

  1. Users are offline 99% of the time so it is usually the right decision to send a push notification
  2. It will cost resources to run some logical check on dynamodb to know if a user is online or offline
  3. It will cost developer time to implement the user activity check
  4. 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.

alionthego avatar alionthego commented on September 18, 2024

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.

fans3210 avatar fans3210 commented on September 18, 2024

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.

fans3210 avatar fans3210 commented on September 18, 2024

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.

bernhardt1 avatar bernhardt1 commented on September 18, 2024

@rohandubal Was an example ever created as you described?

from aws-mobile-appsync-sdk-ios.

bernhardt1 avatar bernhardt1 commented on September 18, 2024

@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.

palpatim avatar palpatim commented on September 18, 2024

Sending this to @nikhil-dabhade to see if this is something we should add to the tutorial docs.

from aws-mobile-appsync-sdk-ios.

btn52396 avatar btn52396 commented on September 18, 2024

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.

palpatim avatar palpatim commented on September 18, 2024

Recategorizing this as a documentation feature request for @nikhil-dabhade.

from aws-mobile-appsync-sdk-ios.

ioschetan avatar ioschetan commented on September 18, 2024

Can we use push sync along with app sync to send the push notification?

from aws-mobile-appsync-sdk-ios.

rohit3d2003 avatar rohit3d2003 commented on September 18, 2024

@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.

Swaroop-Bhupathiraju avatar Swaroop-Bhupathiraju commented on September 18, 2024

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.

bernhardt1 avatar bernhardt1 commented on September 18, 2024

@Swaroop-Bhupathiraju

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.

Swaroop-Bhupathiraju avatar Swaroop-Bhupathiraju commented on September 18, 2024

@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.

Swaroop-Bhupathiraju avatar Swaroop-Bhupathiraju commented on September 18, 2024

Thanks @bernhardt1

from aws-mobile-appsync-sdk-ios.

daghanacay avatar daghanacay commented on September 18, 2024

@bernhardt1

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.

bernhardt1 avatar bernhardt1 commented on September 18, 2024

@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:

  1. mutation comes in to add a chat
  2. The Chat data type has ChainNotification as a field
  3. 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.

daghanacay avatar daghanacay commented on September 18, 2024

from aws-mobile-appsync-sdk-ios.

atierian avatar atierian commented on September 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.