Fragment not Generated in AppSync Sample App - android

I'm going through the sample app for AppSync as described here.
I found a sample Android client app on GitHub here and am trying to just get it to run with my data but for some reason the fragments aren't being generated.
events.graphql has what appears to be the events fragment definition.
fragment Event on Event {
id
description
name
when
where
comments {
items {
eventId
commentId
content
createdAt
}
}
I've tried adding it to the schema in the appsync web interface and it saves the schema but then doesn't actually add the fragment. I'm just now trying GraphQL tonight so I'm not really sure where to even put the fragment definition and Google doesn't seem to have anything about this.

Going to need more information here before answering, but I'm working on the same sample project and was able to get it working so I might be of some help.
Is your project syncing and building? That's a good first step.
It looks like your .graphql files are being autogenerated in your app-> source -> appsync -> com file, but the classes are not being generated in the app -> build -> source -> appsync -> com folder.
Something I learned in the process of working on this project was that it's important to have all your resolvers and the backend set up fairly completely in the AWS console before calling the amplify add api command. Have you setup the back end with resolvers?
If you have and it's still not working, try running in the app terminal amplify gql-compile then running amplify pushto pull the data back into your app from the console, then resync and rebuild as necessary. This should build your Query/Mutation/Subscription classes for you, as well as the Fragment.class, which are the resolvers in your program for the .graphql queries/etc that you want to run in your application.
If that doesn't work, make sure you've completed all the necessary steps in the amplify API like amplify add api, amplify update api. It appears that you've already done that since you have generated .graphql files in the app-> source directory, but in case you haven't, those are first steps. You can also check to make sure that you're actually connected to the DB (and correct api in the console) by running amplify status. Are you connected to the console API that you need to be connected to?
As a last resort, you can copy the Event.class file from github and paste it into the appropriate file/subdirectory, along with the rest of the Query/Mutation/etc .class files that should have been generated by the ApolloGraphql plugin.

Related

No Amplify backend project files detected within this folder

How can I solve the issue of "No Amplify backend project files detected within this folder. Either initialize a new Amplify project or pull an existing project"
Am always having this issue on Windows with Amplify. I am following the TindeClone, just for me to come back to it after I took a break I got "Could not attach the backend to the project. Ensure that there are no applications locking the amplify folder and try again". These issues are frustrating me how how do I solve it and move on.
Here's the screenshot
Thanks for you kind response.
Are you sure you have "amplify" folder one step inside the "TinderClone" folder?
Amplify cli could not locate an amplify folder inside TinderClone.
Try `amplify pull with these steps IN A NEW EMPTY FOLDER.
$ amplify pull
? Select the authentication method you want to use: AWS profile
? Please choose the profile you want to use: (Use arrow keys)
? Please choose the profile you want to use: default
? Which app are you working on? (Use arrow keys)
> amplifyapp (XXXXXXXXXXXXX)
amplifyapp (XXXXXXXXXXXXX)
newsBot (XXXXXXXXXXXXX)
TodoApp (XXXXXXXXXXXXX)
ImageDownloader (XXXXXXXXXXXXX)
it'll fetches resources from the cloud.
Let me know what happened.
Make sure that the .config file exists inside the amplify folder.
It contains all the required configuration files.
Simple delete the amplify folder in your project
run this
amplify pull --appId xxxxx --envName xxxx
and when asked for
Do you want changes backend select yes
This worked for me!
Edit: take special note of Dylan's comment below:
This will erase the amplify project and resources in the cloud, then re-create. You can view instructions how to re-pull the existing environment within the amplify console under the "backend environments tab".
amplify pull --appId {amplify app id} --envName {env name}
I was just recently struggling with the same blocker, after creating/deploying/testing an AWS Amplify project in my personal profile, I added a profile for my "client" (in this case, my brother), who created a specific AWS IAM user for me in his account.
The solution that I discovered, as per this AWS blog post, was to do the following from inside my project root folder:
(if not already done) remove the currently deployed Amplify stack, using amplify delete
delete the local "deployment information" file, using rm amplify/team-provider.info.json
re-initialise a new AWS Amplify stack (i.e.: in the cloud) and generate the relevant local files for it, using amplify init
be sure to select the correct AWS profile or Key here for the new deployment, adding a new one if required..
push your project to the newly initialised AWS Amplify stack, using amplify push for backend-only, or using amplify publish if you use Amplify Hosting
Disclaimer: as I'm still learning AWS, so I may possibly use incorrect terms and/or examples to explain what I've learnt. This answer is most definitely open to clarification by the community.. Either way, I hope it helps.

Firebase console - problem receiving test push FCM notification in android device

I am sending push notification using firebase console and i am getting "0% of potential users are eligible for this campaign: 0". and push notification is not displaying in mobile..If anyone got same experience and solve issue then please suggest me how can i solve this issue. I followed all the thing..that i added json file that i got from firebase.
Please check for the following:
Have you configured your android package name correctly.
Did you place the google-services.json file in android/src folder.
Make sure you have done all steps present in this link (If you using android studio i suggest going with option 2)
Get user token to send firebase message Follow the steps
After all these if you still can't receive push notifications try setting channelid in advanced messaging options
Refer https://firebase.google.com/docs/cloud-messaging/android/client link step by step and you will be good to go for your push notification using fcm and if you already implemented the basic things then compare your code with the sample code step by step mentions on the link. you must find out the error. let me know if it resolves your issue.
Go to Build --> clean project -->Rebuild project
(Build is at top in android studio)
Why it was not working - You must have had deleted google-services.json file and re-added it.
Make sure you have only one firebase project configured for this app (if no then delete one you dont plan to use)
Go to firebase setiings -> Left top angle -> settings icon -> Project settings ->
scroll to bottom, then make sure to add SHA certificate fingerprints Type. How to get it
Then (still on this page) press See SDK instructions button. And place google-services.json file in your project.
If all this steps passed for you and you still getting this error then just wait a little bit, for me it take 2 days, before it started working.

Creating sheet via execution API

I'm trying to create a google sheets document via script, and I'm using the execution API example google provides here:
https://developers.google.com/apps-script/guides/rest/quickstart/android
The only change I've made was a line on the script:
function getFoldersUnderRoot() {
var sheet = SpreadsheetApp.create("MySheet"); //This line.
var root = DriveApp.getRootFolder();
var folders = root.getFolders();
var folderSet = {};
while (folders.hasNext()) {
var folder = folders.next();
folderSet[folder.getId()] = folder.getName();
}
return folderSet;
}
But, even though i can run the code correctly, it just doesnt create the sheet. Maybe some authorization problem? I couldnt find it... Id thank you so much for your help... I really need this to my project.
Based from this guidelines, before using the API you need to do the following to meet the above requirements:
Create an Apps Script project to call, with the functions you want to use. The API can also be used to call existing scripts that were created for other projects. Open the project in the Apps Script editor.
Deploy the script project for execution by selecting Publish > Deploy as API executable. Choose a version (or create a new one) and who has access, then click Deploy. The new dialog that opens shows your script's ID, listed under "Current API ID". Make note of this ID — you need to enter it into the application code so that the API knows which script to call. If you need to find it again later, select Publish > Deploy as API executable in the code editor to see it.
Choose a Cloud Platform project and ensure both the calling application and the target script share it. If you use the script's default Cloud Platform project, the calling application should use that project to set up its OAuth credentials. This requires you to have access to the default Cloud Platform project, which may not be the case if the script resides in Team Drive. If you are using a new or existing Cloud Platform Project, you need to switch the Apps Script project to use it if you have not done so already.
Enable the Google Apps Script Execution API in the Cloud Platform project. You can find directions for doing this in the Execution API Java Quickstart.
Create a valid Client ID and client secret for the application in the Cloud Platform project. This is covered in the Execution API Java Quickstart.
In the application code, generate an OAuth access token for the API call. This is not a token the API itself uses, but rather one the script requires. The token must be built using the Client ID and the scopes from the script (in the editor, under File > Project properties > Scopes). This also requires prompting the user to authorize the script. The Google client libraries, while not strictly necessary, can greatly assist in handling OAuth for the application.
Hope this helps.

How to integrate push services from AWS Mobile Hub sample project in an existing android project?

I have created an android sample project using AWS Mobile Hub with User Sign-In and Push Notifications services.
I've downloaded the project and opened it through Android Studio, in order to take the necessary files for push notifications from the sample project and to integrate it in my existing Android app.
I thought it would be simple, but then I found out this huge files branch:
It is difficult to understand what files I do need and what files I don't need. Could you please help me to figure out what do I need to import into my existing project in order to integrate Push Notifications in my app?
You should copy the contents of MySampleApp/app/src/main/java/com/amazonaws verbatim into your new project and Also parts of AndroidManifest.xml and build.gradle and Application.java.
For a complete instruction, I would recommend that you go through Mobile Hub Console > Project Name > Build > Select Android > On Left side go to develop > Use as an Example.
You will find all the instructions you need for your android project
The "PushListenerService" class is basically a useful example class where the magic happens. So keep every file that support that class. The
private static void generateNotification(Context context, final String message)
is what displays the notification message.
Another important note is how to get the user's device endpoint value. This can be gotten using the "PushManager" class.
String endpoint = pushManager.getEndpointArn();
The endpoint ARN of a device help you send direct notification to that device.
PublishRequest publishRequest = new PublishRequest();
publishRequest.setMessage(message);
publishRequest.setSubject(subject);
publishRequest.withTargetArn(endpoint); //This can also be a "topic" ARN
snsClient.publish(publishRequest);
Pretty nice job done by the guys at AWS. Big thanks to them! :D
There is no easy way out. Just take your time and go through all the code in the classes that relate to the AWS service you want to implement. Good luck!
Btw, make sure your app is not open on the test device when you send a notification to it or else you won't see a notification since your app is already running. I notice this is a default behaviour.

Android Studio cloud end point newly anotated method not showing up

I m new to google cloud endpoint.I m using android studio-0.8.14. I made a new GCM End Point module with the default template.Then I added annotations for find method (which is by default NOT annotated)
#ApiMethod(name = "findDevice")
private RegistrationRecord findRecord(#Named("regId") String regId)
{
return ofy().load().type(RegistrationRecord.class).filter("regId", regId).first().now();
}
After rerunning this module,I dont get the new api for find in my api explorer.I tried rebuilding the project but no luck.I think I need to regenerate the end point library for client. Eclipse had such option but android studio doesnt have that.What if I make a entity model class and then add end point class for that all by myself, without using studio template code, will it show up in explorer?
At last I got it to work BUT after updating the android studio and using their NEW TEMPLATE for endpoint module. The module I created was created before the android studio update beta-0.8.14.That means there must be a bug. Normally a public endpoint method should be exposed to api explorer even if u dont annotate.But in my case it didnt with or without annotation. I did everything ,rebuilding the project, restarting the module backend etc but still no luck. Then I created another project and build anther module with A NEW module-building wizard, I found that the whole project structure changed A LOT...A LOT. Then I added a module (with and without annotation) which just showed up in the API explorer after restarting the backend module. Hence I think the problem must have been in the earlier module template code or somewhere else.

Categories

Resources