Context has not been properly initialized. Please call the .initialize() method to setup your app context object - shopify

I am creating a Shopify Custom App using Reactjs & Nodejs. While installing an app to a shop, I am getting a following error
Context has not been properly initialized. Please call the .initialize() method to setup your app context object.
at UninitializedContextError.ShopifyError [as constructor] (/var/www/didyoubuy.com-server/node_modules/#shopify/koa-shopify-auth/node_modules/#shopify/shopify-api/dist/error.js:13:28)
at new UninitializedContextError (/var/www/didyoubuy.com-server/node_modules/#shopify/koa-shopify-auth/node_modules/#shopify/shopify-api/dist/error.js:63:42)
I am using #shopify/shopify-api#4.0.0 (latest)
any solution???

Related

Vue/Apollo/graphql client cannot read 'watchQuery' error

I'm trying to consume a remote GraphQL API from Vue using the apollo-client library and having trouble. I get:
Error in created hook: "TypeError: Cannot read property 'watchQuery' of undefined"
Code is on github at https://github.com/odessa-paige-turner/vue-apollo-graphql
Have you used Apollo? What has been your experience with it? Any help appreciated.
I solved this by using the plugin (vue add apollo) rather than the manual installation. Then I used the Usage in Vue Components guide to do the rest.

getDevicePushTokenAsync error on bare workflow

I implemented push notification on managed workflow which is working properly but when I eject from managed workflow, I am getting error at line
pushToken = (await Notifications.getExpoPushTokenAsync()).data;
Error: Encountered an exception while calling native method: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Default FirebaseApp is not initialized in this process com.luciajane.taskuser. Make sure to call FirebaseApp.initializeApp(Context) first.
I passed experienceId but still getting error?
pushToken = (await Notifications.getExpoPushTokenAsync({experienceId: "#luciajane/task-user"})).data;
I found reason. You have to setup by making new project on firebase then download google-services.json file and add that to your expo project. As expo mentioned Firebase Cloud Messaging is required for all managed and bare workflow Android apps made with Expo.For setup follow this link https://docs.expo.io/push-notifications/using-fcm/

Freshchat SDK not initialized. Please invoke Freshchat.init() first and invoke showConversations() again

I get an error on a native react project. That's even when I have already implemented Freshchat.init (freshchatConfig) but still get the error as next:
Freshchat SDK not initialized. Please invoke Freshchat.init () first and invoke showConversations () again!
I got this error when running on Android and ios is still running normally.
I fixed it by comment out implementation 'com.google.firebase: firebase-inappmessaging-display: 19.0.7' because it conflicts with freshchat library
I just asked Freshchat Team, and they suggested to implement your own Custom Image Loader class.
Please refer to doc 8.2 Custom Image Loader
It worked for us.

IBM Mobilefirst V8 - Custom Direct update on hybrid application using Ionic v3.20.0 is not happening

I am trying to implement customized direct update in ionic v3.20.0 but while accessing to the below code, am unable to proceed. I can't find any way to do it as the below function is not there in worklight.d.ts file,but can be found at worklight.js file.
The plugin used is cordova-plugin-mfp. The solution provided in the official doc is relevant to only cordova application,that can be done through index.js file which has the function WlCommonInit(). As per the doc the below code is to be called from this function, but unable to do this in ionic-cordova based application.
wl_DirectUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData, directUpdateContext) {
// Implement custom Direct Update logic
};
Pleas refer to the below link for further information.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/direct-update/
Please help me to implement this in ionic v3.20.0 which need to be implemented in typescript. Thanks!.
Presently there is no typescript API for wl_DirectUpdateChallengeHandler in cordova-plugin-mfp to customize direct update in Ionic Applications.
However you can do implementation in the JavaScript and include it in the Ionic Project. Following are the steps :
Create a folder called js inside the path src/assets of the project
Create a new JS file with following code and save it as wldirectudpate.js
function wlCommonInit() {
console.log(">> wlCommonInit() ..." );
wl_DirectUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData, directUpdateContext) {
// Implement custom Direct Update logic
};
};
Add the JS location in index.html file which is located at /src/index.html
<script src="assets/js/wldirectudpate.js"></script>

App crashes on start when remote debugging is disabled

I am trying to install my react-native app on my phone (iPhone). It installs alright but then crashes on start with this error message -
undefined is not an object (evaluating 'navigator.userAgent.indexOf')
<unknown>
:12:71
loadModuleImplementation
require.js:213:12
<unknown>
getScrollPosition.js:12:31
If i then enable remote js debugging, it reloads and everything works fine. I disable remote debugging, the app goes back to crashing. Any idea what might be happening here?
Update - The culprit code is in fbjs package - https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/dom/getDocumentScrollElement.js
They check if navigator is defined or not and then try to access the second level property on it - navigator.userAgent.indexOf.
I can either fake navigator.userAgent somehow or send a PR to fbjs.
navigator is a global Web API available in browsers. This is not available in React Native as it's not a web browser. All of the Web APIs are not part of the global environment. This is why navigator.userAgent.indexOf is throwing the undefined error.
Now the reason why your program runs fine when debugging JS remotely is because React Native will switch to using the JavaScript engine provided by Chrome (or whatever you are debugging through) instead of the core one when you remote debug. So when debugging, you will have access to the global Web API that browsers normally have.
This is a very tricky gotcha that will often trip people up as most people develop with debugging turned on all the time. Rule of thumb: React Native is not a browser. Don't use any of the globals that you would normally use when doing web development and you'll avoid most of these types of gotcha errors.
If you would like to see how these globals are polyfilled (often with empty objects) in React Native's JavaScript engine, you'll want to look at initializeCore.js. Here you can see that React Native will polyfill navigator like this:
// Set up Geolocation
let navigator = global.navigator;
if (navigator === undefined) {
global.navigator = navigator = {};
}
// see https://github.com/facebook/react-native/issues/10881
polyfillObjectProperty(navigator, 'product', () => 'ReactNative');
polyfillObjectProperty(navigator, 'geolocation', () => require('Geolocation'));
Edit: To answer the follow-up and give a workaround.
You can shim it, but you need to do it before importing any of your other files in index.js (the root of your application). This is how it's done in node-libs-react-native with their globals.js file where they too set a default user agent string. Adapting that, you can achieve the same result by doing the following:
Create file to hold your shims, globals.js:
global.navigator.userAgent = 'React Native';
Import/Require it prior to importing any of your other files in index.js:
import { AppRegistry } from "react-native";
import globals from "./globals";
import App from "./App";
AppRegistry.registerComponent("RNSandbox", () => App);
If for some reason you want the userAgent to be different or be dependent on whether you are debugging or not, you can add your own logic to the globals.js.