PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label intercom. Show all posts
Showing posts with label intercom. Show all posts

Sunday, August 21, 2022

[FIXED] How to access environment variables located in .env - React Native

 August 21, 2022     environment-variables, intercom, intercom-ios, react-native     No comments   

Issue

I currently have .env file in which I am saving api keys and such (not actual keys in the example below):

API_URL=https://www.example.si/3000
IOS_API_KEY=738d7hfu3hffsjfsd
STRIPE_KEY=pk_fh843f483ff3f43f34
APP_ID=pk_fh843f483ff3f43f34

I need to access these keys in my AppDelegate.m file.

I've tried the following:

NSString *AppID = @(getenv("APP_ID"));

But it didn't work.I get an error : "***+[NSString stringWithUTF8String:] NULL cString" .

I cannot use variable as @"AppID" where I want to pass it in. Any ideas on how to solve this issue would be helpful.


Solution

I ended up using a library for this, called react-native-config:

https://github.com/luggit/react-native-config

and it works really well. It also has a system in place to avoid delayed (state based) caching so as soon as you save .env file there is no chance of remembering the previous state of .env file.



Answered By - Amadej Ĺ enk
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, January 27, 2022

[FIXED] Can't get variables to work in Wordpress for Intercom Javascript

 January 27, 2022     intercom, javascript, php, wordpress     No comments   

Issue

Intercom provide the following snippet to be injected before the body tag:

<script>
  window.intercomSettings = {
    app_id: "",
    name: "<?php echo json_encode($current_user->name) ?>", // Full name
    email: "<?php echo json_encode($current_user->email) ?>", // Email address
    created_at: "<?php echo strtotime($current_user->created_at) ?>" // Signup date as a Unix timestamp
  };
</script>

However, it creates the launcher with an error; stating to check the email variable. What should the variable be for Wordpress?


Solution

It's not meant to be injected before body, it has to be before the body close tag .

<script>
  window.intercomSettings = {
    app_id: "",
    name: "<?=wp_get_current_user()->user_login?>", // Full name
    email: "<?=wp_get_current_user()->user_email?>", // Email address
    created_at: "<?=strtotime(wp_get_current_user()->created_at)?>" // Signup date as a Unix timestamp
  };
</script>
</body>


Answered By - TheDon
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing