Posts tagged with reactjs

{ "name": "ewf", "adset_id": "120215374042820542", "creative": { "creative_id": "1336302651052048" }, "status": "ACTIVE", "leadgen_form_id": "3944213285856717", "access_token": "EAARyZAITtz6QBO86pyaorCyAa5uij334AFiVizvoL5rnw65FBlnqWQJydGUhd1L6fgfIHmxuNyz2lba3xGj6Y8c1jZCvZBkrZA4sVvoImjNpfBdJrELvylBr8lNm5MpBKrzP7dg9FzLULbt9taTUjxge63my0RhvdKxdHS3BZAsUrbMn8AcJmeBePLZAFcZBGfGIwZDZD" }

This is my first time trying to do react-native bridge. Problem is it always says it couldnt find the dependency, irrespective of my integration, I should be able to download the dependency right? I am trying to bridge: https://developer.imepay.com.np/#/andriod-sdk

I am not being able to implement the dependecy:

implementation 'com.swifttechnology.imepaysdk:payment-service:4.0.1

In my main/java/imepayintegration: ImepayModule.java:

package com.reactnativeimepay; import androidx.annotation.NonNull; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import java.util.Map; import java.util.HashMap; import com.swifttechnology.imepaysdk.IMEPayment; import com.swifttechnology.imepaysdk.IMEPaymentCallback; import com.swifttechnology.imepaysdk.ENVIRONMENT; public class ImepayModule extends ReactContextBaseJavaModule {     private final ReactApplicationContext reactContext;     public ImepayModule(ReactApplicationContext reactContext) {         super(reactContext);         this.reactContext = reactContext;     }     @Override     public String getName() {         return "ImepayModule";     }     @ReactMethod     public void performPayment(String merchantCode, String merchantName, String module,                                String username, String password, String referenceValue,                                String amount, String merchantTransactionRecordingUrl,                                Promise promise) {         IMEPayment imePayment = new IMEPayment(reactContext, ENVIRONMENT.TEST);         imePayment.performPayment(merchantCode,                 merchantName,                 merchantTransactionRecordingUrl,                 amount,                 referenceValue,                 module,                 username,                 password,                 new IMEPaymentCallback() {                     @Override                     public void onSuccess(int responseCode, String responseDescription,                                           String transactionId, String msisdn,                                           String amount, String refId) {                         promise.resolve("Payment successful");                     }                     @Override                     public void onError(int responseCode, String responseDescription) {                         promise.reject("ERROR", responseDescription);                     }                 });     } } 

ImepayPackage.java:

package com.reactnativeimepay; import java.util.Arrays; import java.util.Collections; import java.util.List; import com.facebook.react.ReactPackage; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; public class ImepayPackage implements ReactPackage {     @Override     public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {         return Arrays.<NativeModule>asList(new ImepayModule(reactContext));     }     @Override     public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {         return Collections.emptyList();     } } 

I'm building a solution that'll require me to authenticate Facebook business accounts and get access to their pages and Instagram handles. And my platform will be used to posts and schedule. Just like Ayrshare. How can I get scopes for :-

instagram_business_content_publish pages_manage_posts pages_show_list publish_video

I tried react @greatsumini/react-facebook-login but its not allowing me to add more scopes

<FacebookLogin       appId={process.env.NEXT_PUBLIC_FACEBOOK_ID as string}       onSuccess={FacebookLoginOnSuccess}       onFail={(error) => {         console.log("Login Failed!", error);       }}       onProfileSuccess={FacebookOnProfileSuccess}       style={{         backgroundColor: "#4267b2",         color: "#fff",         fontSize: "16px",         padding: "12px 24px",         border: "none",         borderRadius: "4px",       }}       scope="email,public_profile"     /> 

Page access token expires periodically and if it expires, I need to generate a new one manually.

Is it possible if the page access token can be refresh via code?

Here's my code in react typescript:

const PAGE_ACCESS_TOKEN = "EAAcAHP"; const PAGE_ID = "123456"; export const fetchPageFeed = async () => {   try {     // Fetch page profile picture     const pageInfoResponse = await axios.get(       `https://graph.facebook.com/${PAGE_ID}`,       {         params: {           access_token: PAGE_ACCESS_TOKEN,           fields: "picture{url},name,link",          },       }     );     // Fetch page posts     const postsResponse = await axios.get(       `https://graph.facebook.com/${PAGE_ID}/posts`,       {         params: {           access_token: PAGE_ACCESS_TOKEN,           fields:             "id,message,created_time,picture,full_picture,attachments{media_type,media},reactions.summary(total_count),comments.summary(total_count),shares,video_tags,videos{source,description,thumbnails}",         },       }     );     return {       profilePictureUrl: pageInfoResponse.data.picture.data.url,       pageName: pageInfoResponse.data.name,       pageUrl: pageInfoResponse.data.link,        posts: postsResponse.data.data,     };   } catch (error) {     console.error("Error fetching page feed:", error);     return { profilePictureUrl: "", pageName: "", pageUrl: "", posts: [] };    } }; 

I'm working on a Gatsby.js project that displays ads correctly in production, but not in localhost.

An iframe is supposed to be inserted into the Ad component via a script that is generated by the 'gatsby-browser.js' file. To facilitate this, I've also added another script in the 'gatsby-ssr.js' file to append Google Tags to the Window object, since I was having trouble doing this via the 'onClientEntry' function.

So far, I can generate the required Window objects, and append the script tag to the head tag in the HTML document, but still cannot generate the iframe.

Ad component

import React, { Component } from 'react' class Ad extends Component {   componentDidMount(){     const script=document.createElement('script')     script.src=`${adEmbedCodeURL}`     script.defer=true;     script.setAttribute("data-can-ad","true")     this.instance.appendChild(script)        }   render() {     return (     <div className=`${class-name}` ref={el => (this.instance = el)} >         <p>Advertisement</p>     </div>     )   } } export default AdMPU 

gatsby-browser.js

export const onClientEntry= () => { if (typeof __canGDPR == 'function') {      console.log('onClientEntry')     window.__canGDPR(function() {       console.log('onClientEntry - CANS')       var createScript = function(url, callback) {         var script = document.createElement('script');         script.src = url;         if (callback) {           script.onload = callback;          }document.getElementsByTagName('script')[0].appendChild(script);       };       createScript(`https://www.googletagmanager.com/gtag/js?id=${containerID}`);       window.dataLayer = window.dataLayer || [];       function gtag(){         window.dataLayer.push(arguments);       }gtag('js', new Date());       gtag('config', `${containerID}`);     }); }; } export const onRouteUpdate = () => {     console.log('onRouteUpdate'); if (typeof __canGDPR == 'function') {      window.__canGDPR(function() {       console.log('onRouteUpdate - CANS')       var createScript = function(url, callback) {         var script = document.createElement('script');         script.src = url;         if (callback) {           script.onload = callback;          }document.getElementsByTagName('script')[0].appendChild(script);       };       createScript(`https://www.googletagmanager.com/gtag/js?id=${containerID}`);       window.dataLayer = window.dataLayer || [];       function gtag(){         window.dataLayer.push(arguments);       }gtag('js', new Date());       gtag('config', `${containerID}`);     }); }; } 

gatsby-ssr.js

import React from 'react' export const onRenderBody = ({ setHeadComponents }) => {     setHeadComponents ([     <script       key="SGCCansAds"       src=`${adEmbedCodeURL}`     />,     <script        key="jQuery"        src="https://code.jquery.com/jquery-3.3.1.min.js"     />,     <script     key="gtm-script"     async     src=`https://www.googletagmanager.com/gtag/js?id=${containerID}`   />,   <script     key="gtm-initializer"     dangerouslySetInnerHTML={{       __html: `         window.dataLayer = window.dataLayer || [];         function gtag(){ window.dataLayer.push(arguments); }         gtag('js', new Date());         gtag('config', `${containerID}`);       `,     }}   />,   ]) }