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.
Related
I am struggling to implement Google's Firebase push notifications in a mature MVVMcross application. We are being forced to seek a new solution to our current one because it appears that the functionality is about to be deprecated in AppCenter.
We've placed the code inside the RootActivity file (at the bottom of the method)
protected override void OnCreate(Bundle bundle)
When I run the app in a USB/debug scenario on my Android Galaxy I get the current error "Default FirebaseApp is not initialized in this process"
I tried to use the approach that was recommended in the error message to no avail:
FirebaseApp.InitializeApp(RootActivity.Context);
FirebaseMessaging.Instance.GetToken().AddOnCompleteListener(new OnCompleteListener());
In case anyone is wondering here is the code for the method that is mentioned above was setup for testing purposes using a breakpoint:
public class OnCompleteListener : Java.Lang.Object, IOnCompleteListener
{
public void OnComplete(Android.Gms.Tasks.Task task)
{
var token = task.Result.ToString();
}
}
We initially tested this in a standard Xamarin Forms Android app for testing and didn't have any problem with getting the token but we hit the wall when we played with it in our client's MVVMcross app.
I would also like to mention that I have tried the following solution with no luck as well:
var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(Context);
setupSingleton.EnsureInitialized();
FirebaseMessaging.Instance.GetToken().AddOnCompleteListener(new OnCompleteListener());
I found that I had two problems. The first one was the fact that my project name did not match in my manifest and google services key. I was using my own key that I setup for testing. After I realized this I switched back to my client's key and double checked that it was part of the build. As soon as I resolved that issue I found that I needed to install the nuget package for Xamarin.Google.Dagger to resolve the reflection issues. After taking care of that I did a clean/rebuild and ran the debug on my Galaxy S20 test device. This fix allowed me to hit my test break point that I setup for testing the token reception from FCM.
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.
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.
I'm trying to use FCM push notifications with my Ionic 2 app via cordova-fcm-plugin.
I've followed every tutorial and it's working fine when i send a push from the firebase console, but i want to do some stuff in my app using its functionalities and the payload, but when i try to use any method from the plugin i get a Cannot find name 'FCMPlugin' error on Visual Studio:
The error
I've been looking for how to use it correctly and haven't found anything, just this question: The Question
So what is the correctly way to implement and use the plugin? Is there a module? I can call it from the 'ionic-native'? I have to import it from somewhere? Just use the plugin .js file link in the index.html? Or this error is commom and in emulation/building it'll work fine?
Thanks :D
PS: I've not tryed to build it or emulate it to see what happens, going to do this now.
EDIT
Ok, so it's an error that won't let me build my app. Rly need to know how to use the plugin now.
You have to declare the FCMPlugin variable after your imports:
import { Foo} from '../pages/foo/foo';
import { Bar } from '../pages/bar/bar';
declare var FCMPlugin: any; // <---- this is the magic line
On eclipse (appengine -> android) , how can i update the libraries that are generated by the command
'Generate cloud endpoint client library', so that it will then always generate the updated version ?
I mean google-api-client-1.18.0.jar to google-api-client-1.20.0.jar for example.
Where do they come from?
Thanks!
Your endpoint libraries are updated automatically each time you generate them from the backend project. If you don't see a class or a method, most probably it is due to one of the following:
1. a method is marked static and public. Make it private and manually add the #Apimethod annotation.
2. Also, sometimes the name of the endpoint library is different from the original class name in the backend project. Pay attention to the name attribute of the #Api annotation on the class name.
You may find these links useful:
https://cloud.google.com/appengine/docs/java/endpoints/annotations#api_api-scoped_annotations
https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android/
Hope this resolves ur issue