Posts

React Native error - Cannot find module 'metro-react-native-babel-preset'

Image
I created a React native app using "react-native init <App Name> " but received below error when try to run it in Simulator: Cannot find module 'metro-react-native-babel-preset' I resolved the error by adding below line under "dependencies" in package.json.     "@babel/runtime": "^7.0.0-beta.55"  Run "npm i", and then run the app successfully. :) Further Study     I had been studied the online course " The Complete React Native and Redux Course ", it gave me the clear explanation and instruction with step by step procedures to learn the core knowledge to build React components for mobile devices. It's suitable for all levels. The course has sample code and completed projects in gitHub.com. Instructor : Stephen Grider -  Engineering Architect, Stephen Grider has been building complex Javascript front ends for top corporations in the San Francisco Bay Area.

Javascript - Equivalent of .NET DateTime.MaxValue.Ticks

According to article "Azure Storage Table Design Guide: Designing Scalable and Performant Tables" " https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-design-guide#log-tail-pattern ". The below code is used to store the entities using a RowKey that naturally sorts in reverse date/time order by using so the most recent entry is always the first one in the table. string invertedTicks = string.Format("{0:D19}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks); The Equivalent JavaScript code is as below: var currentTimeInMilliseconds=moment().add(-2, 'hours').valueOf() * 10000 + 621355968000000000; //MaxTime is the DateTime.MaxValue.Ticks var MaxTime = 3155378975999999999; var rowKey =(MaxTime - currentTimeInMilliseconds).toString();

Javascript - Handing XML document with prefix and name space

If you need to process XML string with  namespace such as  "<book xmlns:xi='http://www.w3.org/2001/XInclude'>     <Name>Some text</Name>     <Price>$12</Price> </book>"  , then you can use " getElementsByTagNameNS " function to process it. Its formula is:   elements = element.getElementsByTagNameNS(namespaceURI, localName) Below code is th example of using   " getElementsByTagNameNS " function and explore XML child nodes  in JavaScript. var z=xmlDocument. getElementsByTagNameNS(' http:/ /schemas.microsoft.com/ado/ 2007/08/dataservices ', 'Rows'); x=z[0].firstElementChild.childNodes; for (i = 0; i < x.length ;i++)  {      console.log(x[i].firstChild);       if (x[i].firstChild.innerHTML=="URL")        {                    console.log(x[i].children[1]. innerHTML);   ...

Handle "Forgot your password" / "Reset password" in Azure B2C Activity Directory "SignInSignUp" policy

Image
When you use Azure B2C Activity Directory "SignInSignUp" policy in your application, then you will see below screen shot signin /signup pop up window. If you click on "Forgot your password?", and the login is failure at this code " await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, Authority) ;". You can catch this error and the error message should contains "AADB2C90118", and then you can handle this error to invoke "Reset Password Service" with following code:  AuthenticationResult authResult= await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, AuthorityResetPassword);    You can retrieve user name and "id_token" from "authResult" from above code. Refer to Azure B2C sample project " https://github.com...

Passing string value to lambda function

I wrote a lambda function which accepts "string" type parameter. When I tried to invoke this function within another lambda function, it needs to enter the value to pass to the function to execute. So I entered the value "XXX". However, it throws the error "can't convert this JSON document into a string" when I pass the Guid value as a string. To resolve the issue, I add "\" to include the Guid value like "\""+m.messageId.toString()+"\"". The error is gone and the the value is passed to the function.

Fixed Facebook App login issue "The domain of this URL isn't included in the app's domains"

I have been setup and use the Facebook login successfully i my UWP app for sometime. But recent it was failure with error " Can't load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and sub-domains of your app to the App Domains field in your app settings " when I running the app in "Release" mode in Visual Studio. I am using URL " https://www.facebook.com/v2.12/dialog/oauth?client_id=<XXXX>&redirect_uri=ms-app://{ Windows Store SID }&display=popup&response_type=token&state=1&scope=email ", I found the redirect_uri value which got from the code "WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri" is changed and not the sane value in the Facebook App setting's Windows Store ID. So I updated the new value to App Settings and then run above URL again, it works! Login to Facebook successfully. By the way, I used "https...