intercom https://www.e-learn.cn/tag/intercom zh-hans PHP-intercom not working after updating composer https://www.e-learn.cn/topic/3134713 <span>PHP-intercom not working after updating composer</span> <span><span lang="" about="/user/199" typeof="schema:Person" property="schema:name" datatype="">北城以北</span></span> <span>2020-01-06 16:04:08</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>i recently updated using composer. After updating I am getting error in php file , where I am sending data to intercom. This is the error : </p> <pre><code>Fatal error: Class 'Intercom\IntercomBasicAuthClient' not found in &lt;filename&gt; </code></pre> <p>I found a similar problem here Symfony Exception (Class not found) only on development and production servers. But couldn't understand exactly how to solve the issue. I tried using intercom in Uppercase as well as lowercase, but problem is not solved.</p> <p>In my installed.json I found this :</p> <pre><code>"autoload": { "psr-4": { "Intercom\\": [ "src" ] } } </code></pre> <p>And this is the directory location of intercom files :</p> <pre><code>/public_html/vendor/intercom/intercom-php/src </code></pre> <p>When I dig into more composers file(was trying to understand how classes are included and all), I came across this code in autoload_namespaces.json</p> <pre><code>&lt;?php // autoload_namespaces.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'libphonenumber' =&gt; array($vendorDir . '/giggsey/libphonenumber-for-php/src'), 'PhpAmqpLib' =&gt; array($vendorDir . '/php-amqplib/php-amqplib'), ); </code></pre> <p>libphonenumber and phpamqplib are two libraries that I installed using composer, and intercom is missing here.</p> <p>So I am totally confused, what is the actual problem. Is the intercom library missing in autoload_namespace or is it the uppercase-lowercase issue or what.</p> <p>Edit : </p> <p>This I found in autoload_psr4.php</p> <pre><code>&lt;?php // autoload_psr4.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'Psr\\Http\\Message\\' =&gt; array($vendorDir . '/psr/http-message/src'), 'JmesPath\\' =&gt; array($vendorDir . '/mtdowling/jmespath.php/src'), 'Intercom\\' =&gt; array($vendorDir . '/intercom/intercom-php/src'), 'GuzzleHttp\\Psr7\\' =&gt; array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' =&gt; array($vendorDir . '/guzzlehttp/promises/src'), 'GuzzleHttp\\' =&gt; array($vendorDir . '/guzzlehttp/guzzle/src'), 'Aws\\' =&gt; array($vendorDir . '/aws/aws-sdk-php/src'), ); </code></pre> <p>And this is how I am including Intercom in my php file :</p> <pre><code>use Intercom\IntercomBasicAuthClient; </code></pre> <br /><h3>回答1:</h3><br /><p>I figured it out myself. The problem was with PHP version. I am using php-5.5 and the intercom library strictly requires PHP version &gt;= 5.6 .</p> <p>Created my own library using Intercom APIs to get it work for php-5.5.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/38832607/php-intercom-not-working-after-updating-composer</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/namespaces" hreflang="zh-hans">namespaces</a></div> <div class="field--item"><a href="/tag/composer-php" hreflang="zh-hans">composer-php</a></div> <div class="field--item"><a href="/tag/autoloader" hreflang="zh-hans">autoloader</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> </div> </div> Mon, 06 Jan 2020 08:04:08 +0000 北城以北 3134713 at https://www.e-learn.cn PHP-intercom not working after updating composer https://www.e-learn.cn/topic/3134708 <span>PHP-intercom not working after updating composer</span> <span><span lang="" about="/user/235" typeof="schema:Person" property="schema:name" datatype="">你。</span></span> <span>2020-01-06 16:03:52</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>i recently updated using composer. After updating I am getting error in php file , where I am sending data to intercom. This is the error : </p> <pre><code>Fatal error: Class 'Intercom\IntercomBasicAuthClient' not found in &lt;filename&gt; </code></pre> <p>I found a similar problem here Symfony Exception (Class not found) only on development and production servers. But couldn't understand exactly how to solve the issue. I tried using intercom in Uppercase as well as lowercase, but problem is not solved.</p> <p>In my installed.json I found this :</p> <pre><code>"autoload": { "psr-4": { "Intercom\\": [ "src" ] } } </code></pre> <p>And this is the directory location of intercom files :</p> <pre><code>/public_html/vendor/intercom/intercom-php/src </code></pre> <p>When I dig into more composers file(was trying to understand how classes are included and all), I came across this code in autoload_namespaces.json</p> <pre><code>&lt;?php // autoload_namespaces.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'libphonenumber' =&gt; array($vendorDir . '/giggsey/libphonenumber-for-php/src'), 'PhpAmqpLib' =&gt; array($vendorDir . '/php-amqplib/php-amqplib'), ); </code></pre> <p>libphonenumber and phpamqplib are two libraries that I installed using composer, and intercom is missing here.</p> <p>So I am totally confused, what is the actual problem. Is the intercom library missing in autoload_namespace or is it the uppercase-lowercase issue or what.</p> <p>Edit : </p> <p>This I found in autoload_psr4.php</p> <pre><code>&lt;?php // autoload_psr4.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'Psr\\Http\\Message\\' =&gt; array($vendorDir . '/psr/http-message/src'), 'JmesPath\\' =&gt; array($vendorDir . '/mtdowling/jmespath.php/src'), 'Intercom\\' =&gt; array($vendorDir . '/intercom/intercom-php/src'), 'GuzzleHttp\\Psr7\\' =&gt; array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' =&gt; array($vendorDir . '/guzzlehttp/promises/src'), 'GuzzleHttp\\' =&gt; array($vendorDir . '/guzzlehttp/guzzle/src'), 'Aws\\' =&gt; array($vendorDir . '/aws/aws-sdk-php/src'), ); </code></pre> <p>And this is how I am including Intercom in my php file :</p> <pre><code>use Intercom\IntercomBasicAuthClient; </code></pre> <br /><h3>回答1:</h3><br /><p>I figured it out myself. The problem was with PHP version. I am using php-5.5 and the intercom library strictly requires PHP version &gt;= 5.6 .</p> <p>Created my own library using Intercom APIs to get it work for php-5.5.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/38832607/php-intercom-not-working-after-updating-composer</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/php" hreflang="zh-hans">php</a></div> <div class="field--item"><a href="/tag/namespaces" hreflang="zh-hans">namespaces</a></div> <div class="field--item"><a href="/tag/composer-php" hreflang="zh-hans">composer-php</a></div> <div class="field--item"><a href="/tag/autoloader" hreflang="zh-hans">autoloader</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> </div> </div> Mon, 06 Jan 2020 08:03:52 +0000 你。 3134708 at https://www.e-learn.cn Why substring “com.” in GoogleScript convert to “(class)” https://www.e-learn.cn/topic/2897632 <span>Why substring “com.” in GoogleScript convert to “(class)”</span> <span><span lang="" about="/user/184" typeof="schema:Person" property="schema:name" datatype="">柔情痞子</span></span> <span>2019-12-24 20:16:51</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Today, the Google script has stopped representing the line normally. In case of occurrence of a line "com." or "org." - substring is replaced by a certain class "(class)". How to fix the problem?</p> <pre><code>function myFunction2() { var t = "testcom.io"; t = t + '1'; t=t; } </code></pre> <p>screenshot from editor https://i.stack.imgur.com/hldbz.png</p> <p>The logger shows the result as well as you do. But during the debugging, the value of the variable T changes. Because of this error, URL Feth does not work. A full script was written a few months ago and worked until today.</p> <p>You can look error on the next screenshot. We have var url = 'api.intercom.io';; When we try run function we see </p> <blockquote> <p>error 406 </p> </blockquote> <p>and message where var url is changed to api.intercom.io';. In case of occurrence of a line "com." or "org." - substring is replaced by a certain class "(class)" or symbols .</p> <pre><code>function myFunction3() { var url = 'https://api.intercom.io'; var response = UrlFetchApp.fetch(url,options); Logger.log(response.getContentText()); } </code></pre> <p>look at screenshot</p> <br /><h3>回答1:</h3><br /><p>I think that <code>test(class)</code> is not the value of <code>t</code> rather that's the class to which this particular t variable belongs.</p> <p>You can turn your function into something like this : </p> <p>Then check the log to see value of t </p> <p>Let me know if you need anymore help.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/49273513/why-substring-com-in-googlescript-convert-to-class</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/google-apps-script" hreflang="zh-hans">google-apps-script</a></div> <div class="field--item"><a href="/tag/http-status-code-406" hreflang="zh-hans">http-status-code-406</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> </div> </div> Tue, 24 Dec 2019 12:16:51 +0000 柔情痞子 2897632 at https://www.e-learn.cn Intercom.io Custom Attributes for Swift aren't working https://www.e-learn.cn/topic/2779608 <span>Intercom.io Custom Attributes for Swift aren&#039;t working</span> <span><span lang="" about="/user/25" typeof="schema:Person" property="schema:name" datatype="">做~自己de王妃</span></span> <span>2019-12-23 01:34:06</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I'm trying to implement custom attributes for Intercom.io into my iOS app. I'm in XCode 7, Swift 2 and iOS 9.</p> <p>Here's my code:</p> <pre><code>class func updateUser(user: User) { Intercom.updateUserWithAttributes([ "name": user.name, "email": user.email ]) let userAttributes = ([ "role": "customer", "phone": user.phone, "First Name": user.firstName, "Last Name": user.lastName, "Referral Code": user.referralCode, "Avatar Pic": user.avatarURL, "Profile Pic": user.profilePicURL ]) Intercom.updateUserWithAttributes(["custom_attributes": userAttributes]) } </code></pre> <p>I am successfully submitting "name" &amp; "email" but my "custom_attributes" aren't working. I think my syntax is correct according to the Intercom's documentation: https://docs.intercom.io/Install-on-your-mobile-product/configuring-intercom-for-ios</p> <p>But I'm a Swift newbie and have no experience with Obj-C.</p> <p>Also important to note that my events are reporting properly through.</p> <pre><code>Intercom.logEventWithName(eventName) </code></pre> <p>Is there anything wrong with my syntax?? Or anything else? Please help!</p> <br /><h3>回答1:</h3><br /><p>Turns out there were two issues:</p> <p>1) Intercom documentation wrong and "custom_attributes" tag not needed for custom attributes</p> <p>2) my URL formats were NSURL and not Strings and therefore the whole object was getting rejected</p> <p>Fixed now! Thanks to Dale from Intercom for the support</p> <p>the code is simply:</p> <pre><code>let userAttributes = [ "name": user.name, "email": user.email, "role": "customer", "phone": user.phone, "first_name": user.firstName, "last_name": user.lastName, "referral_code": user.referralCode, "avatar_pic": user.avatarURLString, "profile_pic": user.profilePicURLString ] Intercom.updateUserWithAttributes(userAttributes) </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/33187287/intercom-io-custom-attributes-for-swift-arent-working</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/ios" hreflang="zh-hans">ios</a></div> <div class="field--item"><a href="/tag/swift" hreflang="zh-hans">swift</a></div> <div class="field--item"><a href="/tag/swift2" hreflang="zh-hans">swift2</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> <div class="field--item"><a href="/tag/intercom-ios" hreflang="zh-hans">intercom-ios</a></div> </div> </div> Sun, 22 Dec 2019 17:34:06 +0000 做~自己de王妃 2779608 at https://www.e-learn.cn call a function every time a route is updated vue.js https://www.e-learn.cn/topic/2080022 <span>call a function every time a route is updated vue.js</span> <span><span lang="" about="/user/7" typeof="schema:Person" property="schema:name" datatype="">▼魔方 西西</span></span> <span>2019-12-10 09:26:16</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have integrated intercom in my app and I need to call <code>window.Intercom('update');</code> every-time my url changes.</p> <p>I know I could add it on <code>mounted()</code> but I rather not modify all my component and do it directly using the navigation guards. (Mainly to avoid to have the same code in 10 different places.</p> <p>At the moment I have:</p> <pre><code>router.afterEach((to, from) =&gt; { eventHub.$off(); // I use this for an other things, here is not important console.log(window.location.href ) // this prints the previous url window.Intercom('update'); // which means that this also uses the previous url }) </code></pre> <p>This runs <code>intercom('update')</code> before changing the url, while I need to run it after the url changes. </p> <p>Is there a hook which runs just when the url has changed? How can I do this?</p> <p>Thanks</p> <br /><h3>回答1:</h3><br /><p>Wasn't sure this would work as what you already have seems like it should be fine but here goes...</p> <p>Try watching the $route object for changes</p> <pre><code>new Vue({ // ... watch: { '$route': function(to, from) { Intercom('update') } } }) </code></pre> <br /><br /><br /><h3>回答2:</h3><br /><p>I just came up with another solution beyond Phil's, you could also use Global Mixin. It merges its methods or lifecycle hooks into every component.</p> <pre><code>Vue.mixin({ mounted() { // do what you need } }) </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/45602622/call-a-function-every-time-a-route-is-updated-vue-js</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/javascript" hreflang="zh-hans">javascript</a></div> <div class="field--item"><a href="/tag/vuejs2" hreflang="zh-hans">vuejs2</a></div> <div class="field--item"><a href="/tag/vue-component" hreflang="zh-hans">vue-component</a></div> <div class="field--item"><a href="/tag/vue-router" hreflang="zh-hans">vue-router</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> </div> </div> Tue, 10 Dec 2019 01:26:16 +0000 ▼魔方 西西 2080022 at https://www.e-learn.cn Intercom.io Custom Attributes for Swift aren't working https://www.e-learn.cn/topic/1851798 <span>Intercom.io Custom Attributes for Swift aren&#039;t working</span> <span><span lang="" about="/user/53" typeof="schema:Person" property="schema:name" datatype="">依然范特西╮</span></span> <span>2019-12-06 14:46:54</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><div class="alert alert-danger" role="alert"> <p>I'm trying to implement custom attributes for Intercom.io into my iOS app. I'm in XCode 7, Swift 2 and iOS 9.</p> <p>Here's my code:</p> <pre><code>class func updateUser(user: User) { Intercom.updateUserWithAttributes([ "name": user.name, "email": user.email ]) let userAttributes = ([ "role": "customer", "phone": user.phone, "First Name": user.firstName, "Last Name": user.lastName, "Referral Code": user.referralCode, "Avatar Pic": user.avatarURL, "Profile Pic": user.profilePicURL ]) Intercom.updateUserWithAttributes(["custom_attributes": userAttributes]) } </code></pre> <p>I am successfully submitting "name" &amp; "email" but my "custom_attributes" aren't working. I think my syntax is correct according to the Intercom's documentation: <a href="https://docs.intercom.io/Install-on-your-mobile-product/configuring-intercom-for-ios" rel="nofollow">https://docs.intercom.io/Install-on-your-mobile-product/configuring-intercom-for-ios</a></p> <p>But I'm a Swift newbie and have no experience with Obj-C.</p> <p>Also important to note that my events are reporting properly through.</p> <pre><code>Intercom.logEventWithName(eventName) </code></pre> <p>Is there anything wrong with my syntax?? Or anything else? Please help!</p> </div><div class="panel panel-info"><div class="panel-heading"></div><div class="panel-body"> <p>Turns out there were two issues:</p> <p>1) Intercom documentation wrong and "custom_attributes" tag not needed for custom attributes</p> <p>2) my URL formats were NSURL and not Strings and therefore the whole object was getting rejected</p> <p>Fixed now! Thanks to Dale from Intercom for the support</p> <p>the code is simply:</p> <pre><code>let userAttributes = [ "name": user.name, "email": user.email, "role": "customer", "phone": user.phone, "first_name": user.firstName, "last_name": user.lastName, "referral_code": user.referralCode, "avatar_pic": user.avatarURLString, "profile_pic": user.profilePicURLString ] Intercom.updateUserWithAttributes(userAttributes) </code></pre> </div></div><div class="alert alert-warning" role="alert"><p>来源:<code>https://stackoverflow.com/questions/33187287/intercom-io-custom-attributes-for-swift-arent-working</code></p></div></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/ios" hreflang="zh-hans">ios</a></div> <div class="field--item"><a href="/tag/swift" hreflang="zh-hans">swift</a></div> <div class="field--item"><a href="/tag/swift2" hreflang="zh-hans">swift2</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> <div class="field--item"><a href="/tag/intercom-ios" hreflang="zh-hans">intercom-ios</a></div> </div> </div> Fri, 06 Dec 2019 06:46:54 +0000 依然范特西╮ 1851798 at https://www.e-learn.cn PODS_ROOT and other pods env variables not set when compiling Ionic app https://www.e-learn.cn/topic/1768139 <span>PODS_ROOT and other pods env variables not set when compiling Ionic app</span> <span><span lang="" about="/user/76" typeof="schema:Person" property="schema:name" datatype="">时光毁灭记忆、已成空白</span></span> <span>2019-12-06 01:50:00</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have built an Ionic 2 app which uses Intercom (a third-party extension). Intercom is installed using cocoapods.</p> <p>When compiling my app I am given the errors:</p> <pre><code>diff: /Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. </code></pre> <p>This is being generated by the Build Phase <code>[CP] Check Pods Manifest.lock</code>:</p> <pre><code>diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" &gt; /dev/null if [ $? != 0 ] ; then # print error to STDERR echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." &gt;&amp;2 exit 1 fi # This output is used by Xcode 'outputs' to avoid re-running this script phase. echo "SUCCESS" &gt; "${SCRIPT_OUTPUT_FILE_0}" </code></pre> <p>I have tried outputting the environment variables <code>PODS_PODFILE_DIR_PATH</code> and <code>PODS_ROOT</code> in the <code>STDERROR</code> <code>echo</code> from the script above and both are blank. I can probably get around this specific error by amending those paths myself, but clearly something else more fundamental is broken, so I need to fix the actual issue itself.</p> <p>Why are these variables blank?</p> <p>I have additional build phases for <code>[CP] Copy Pods Resources</code> and <code>[CP] Embed Pods Frameworks</code> which run some shell scripts. I have tried changing the order of these with no luck.</p> <p>My Podfile.lock and Podfile (which was auto-generated anyway) both seem good:</p> <p>Podfile:</p> <pre><code># DO NOT MODIFY -- auto-generated by Apache Cordova platform :ios, '8.0' target 'niix' do project 'niix.xcodeproj' pod 'Intercom', '~&gt; 3.2.2' end </code></pre> <p>Podfile.lock:</p> <pre><code>PODS: - Intercom (3.2.12) DEPENDENCIES: - Intercom (~&gt; 3.2.2) SPEC CHECKSUMS: Intercom: 3119e8ebf76d3da425bab717a08067398fcabfe6 PODFILE CHECKSUM: f99283bb8a4e56cb037a02390d2fbc4e76c97db9 COCOAPODS: 1.3.1 </code></pre> <p>There are no errors when running <code>pod install</code>, and all files I expect are present.</p> <p>Things I have tried already:</p> <ul><li>Running <code>pod install</code> (of course)</li> <li>Running <code>pod deintegrate</code>, running Product &gt; Clean in XCode, re-running <code>pod install</code></li> <li>Manually deleting the <code>Podfile.lock</code> and <code>Pods</code> directory, running a Clean in XCode and then re-running <code>pod install</code></li> <li>A good nights sleep and another attempt the next morning!</li> </ul><p>Things to note:</p> <ul><li>I am running from <code>project.xcworkspace</code> not <code>project.xcodeproj</code></li> <li>I am running the latest stable version of XCode 8.3.3</li> <li>I am running the latest version of Cocoapods 1.3.1</li> </ul><br /><h3>回答1:</h3><br /><p>I've spent a long time trying to work this out and got nowhere. The app was built using Ionic 2, so the actual source code is stored elsewhere and built into a native XCode application.</p> <p>Because of this I decided to delete the entire XCode directory. <code>.xcodeproj</code>, <code>.xcworkspace</code>, everything. I then rebuilt from Ionic.</p> <p>On the second build I saw thats the <code>Pods</code> directory was there and everything was as it should be. I could compile and run first time without any issue.</p> <p>My assumption is that the first build failed because I didn't have Cocoapods installed, so Ionic silently failed to run the <code>pod install</code> command upon set up. I guess it does something a little different to a traditional setup which is why I couldn't just run <code>pod install</code> afterwards.</p> <p>So, in short, this was fixed by removing the iOS project:</p> <pre><code>ionic cordova platform rm ios </code></pre> <p>And re-adding it:</p> <pre><code>ionic cordova platform add ios </code></pre> <p>And then building:</p> <pre><code>ionic cordova run ios --device </code></pre> <p>But make sure you already have Cocoapods installed on your system first.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/46110728/pods-root-and-other-pods-env-variables-not-set-when-compiling-ionic-app</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/ios" hreflang="zh-hans">ios</a></div> <div class="field--item"><a href="/tag/xcode" hreflang="zh-hans">xcode</a></div> <div class="field--item"><a href="/tag/cocoapods" hreflang="zh-hans">cocoapods</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> <div class="field--item"><a href="/tag/intercom-ios" hreflang="zh-hans">intercom-ios</a></div> </div> </div> Thu, 05 Dec 2019 17:50:00 +0000 时光毁灭记忆、已成空白 1768139 at https://www.e-learn.cn call a function every time a route is updated vue.js https://www.e-learn.cn/topic/1724730 <span>call a function every time a route is updated vue.js</span> <span><span lang="" about="/user/99" typeof="schema:Person" property="schema:name" datatype="">牧云@^-^@</span></span> <span>2019-12-05 16:18:46</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><div class="alert alert-danger" role="alert"> <p>I have integrated intercom in my app and I need to call <code>window.Intercom('update');</code> every-time my url changes.</p> <p>I know I could add it on <code>mounted()</code> but I rather not modify all my component and do it directly using the <a href="https://router.vuejs.org/en/advanced/navigation-guards.html" rel="nofollow">navigation guards</a>. (Mainly to avoid to have the same code in 10 different places.</p> <p>At the moment I have:</p> <pre><code>router.afterEach((to, from) =&gt; { eventHub.$off(); // I use this for an other things, here is not important console.log(window.location.href ) // this prints the previous url window.Intercom('update'); // which means that this also uses the previous url }) </code></pre> <p>This runs <code>intercom('update')</code> before changing the url, while I need to run it after the url changes. </p> <p>Is there a hook which runs just when the url has changed? How can I do this?</p> <p>Thanks</p> </div><div class="panel panel-info"><div class="panel-heading"></div><div class="panel-body"> <p>Wasn't sure this would work as what you already have seems like it should be fine but here goes...</p> <p>Try <a href="https://router.vuejs.org/en/essentials/dynamic-matching.html#reacting-to-params-changes" rel="nofollow">watching the <code>$route</code> object</a> for changes</p> <pre><code>new Vue({ // ... watch: { '$route': function(to, from) { Intercom('update') } } }) </code></pre> </div></div><div class="panel panel-info"><div class="panel-heading"></div><div class="panel-body"> <p>I just came up with another solution beyond Phil's, you could also use <a href="https://vuejs.org/v2/guide/mixins.html#Global-Mixin" rel="nofollow">Global Mixin</a>. It merges its methods or lifecycle hooks into every component.</p> <pre><code>Vue.mixin({ mounted() { // do what you need } }) </code></pre> </div></div><div class="alert alert-warning" role="alert"><p>来源:<code>https://stackoverflow.com/questions/45602622/call-a-function-every-time-a-route-is-updated-vue-js</code></p></div></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/javascript" hreflang="zh-hans">javascript</a></div> <div class="field--item"><a href="/tag/vuejs2" hreflang="zh-hans">vuejs2</a></div> <div class="field--item"><a href="/tag/vue-component" hreflang="zh-hans">vue-component</a></div> <div class="field--item"><a href="/tag/vue-router" hreflang="zh-hans">vue-router</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> </div> </div> Thu, 05 Dec 2019 08:18:46 +0000 牧云@^-^@ 1724730 at https://www.e-learn.cn PODS_ROOT and other pods env variables not set when compiling Ionic app https://www.e-learn.cn/topic/1540667 <span>PODS_ROOT and other pods env variables not set when compiling Ionic app</span> <span><span lang="" about="/user/98" typeof="schema:Person" property="schema:name" datatype="">六眼飞鱼酱①</span></span> <span>2019-12-04 07:59:54</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><div class="alert alert-danger" role="alert"> <p>I have built an Ionic 2 app which uses Intercom (a third-party extension). Intercom is installed using cocoapods.</p> <p>When compiling my app I am given the errors:</p> <pre><code>diff: /Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. </code></pre> <p>This is being generated by the Build Phase <code>[CP] Check Pods Manifest.lock</code>:</p> <pre><code>diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" &gt; /dev/null if [ $? != 0 ] ; then # print error to STDERR echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." &gt;&amp;2 exit 1 fi # This output is used by Xcode 'outputs' to avoid re-running this script phase. echo "SUCCESS" &gt; "${SCRIPT_OUTPUT_FILE_0}" </code></pre> <p>I have tried outputting the environment variables <code>PODS_PODFILE_DIR_PATH</code> and <code>PODS_ROOT</code> in the <code>STDERROR</code> <code>echo</code> from the script above and both are blank. I can probably get around this specific error by amending those paths myself, but clearly something else more fundamental is broken, so I need to fix the actual issue itself.</p> <p>Why are these variables blank?</p> <p>I have additional build phases for <code>[CP] Copy Pods Resources</code> and <code>[CP] Embed Pods Frameworks</code> which run some shell scripts. I have tried changing the order of these with no luck.</p> <p>My Podfile.lock and Podfile (which was auto-generated anyway) both seem good:</p> <p>Podfile:</p> <pre><code># DO NOT MODIFY -- auto-generated by Apache Cordova platform :ios, '8.0' target 'niix' do project 'niix.xcodeproj' pod 'Intercom', '~&gt; 3.2.2' end </code></pre> <p>Podfile.lock:</p> <pre><code>PODS: - Intercom (3.2.12) DEPENDENCIES: - Intercom (~&gt; 3.2.2) SPEC CHECKSUMS: Intercom: 3119e8ebf76d3da425bab717a08067398fcabfe6 PODFILE CHECKSUM: f99283bb8a4e56cb037a02390d2fbc4e76c97db9 COCOAPODS: 1.3.1 </code></pre> <p>There are no errors when running <code>pod install</code>, and all files I expect are present.</p> <p>Things I have tried already:</p> <ul><li>Running <code>pod install</code> (of course)</li> <li>Running <code>pod deintegrate</code>, running Product &gt; Clean in XCode, re-running <code>pod install</code></li> <li>Manually deleting the <code>Podfile.lock</code> and <code>Pods</code> directory, running a Clean in XCode and then re-running <code>pod install</code></li> <li>A good nights sleep and another attempt the next morning!</li> </ul><p>Things to note:</p> <ul><li>I am running from <code>project.xcworkspace</code> not <code>project.xcodeproj</code></li> <li>I am running the latest stable version of XCode 8.3.3</li> <li>I am running the latest version of Cocoapods 1.3.1</li> </ul></div><div class="panel panel-info"><div class="panel-heading"></div><div class="panel-body"> <p>I've spent a long time trying to work this out and got nowhere. The app was built using Ionic 2, so the actual source code is stored elsewhere and built into a native XCode application.</p> <p>Because of this I decided to delete the entire XCode directory. <code>.xcodeproj</code>, <code>.xcworkspace</code>, everything. I then rebuilt from Ionic.</p> <p>On the second build I saw thats the <code>Pods</code> directory was there and everything was as it should be. I could compile and run first time without any issue.</p> <p>My assumption is that the first build failed because I didn't have Cocoapods installed, so Ionic silently failed to run the <code>pod install</code> command upon set up. I guess it does something a little different to a traditional setup which is why I couldn't just run <code>pod install</code> afterwards.</p> <p>So, in short, this was fixed by removing the iOS project:</p> <pre><code>ionic cordova platform rm ios </code></pre> <p>And re-adding it:</p> <pre><code>ionic cordova platform add ios </code></pre> <p>And then building:</p> <pre><code>ionic cordova run ios --device </code></pre> <p>But make sure you already have Cocoapods installed on your system first.</p> </div></div><div class="alert alert-warning" role="alert"><p>来源:<code>https://stackoverflow.com/questions/46110728/pods-root-and-other-pods-env-variables-not-set-when-compiling-ionic-app</code></p></div></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/ios" hreflang="zh-hans">ios</a></div> <div class="field--item"><a href="/tag/xcode" hreflang="zh-hans">xcode</a></div> <div class="field--item"><a href="/tag/cocoapods" hreflang="zh-hans">cocoapods</a></div> <div class="field--item"><a href="/tag/intercom" hreflang="zh-hans">intercom</a></div> <div class="field--item"><a href="/tag/intercom-ios" hreflang="zh-hans">intercom-ios</a></div> </div> </div> Tue, 03 Dec 2019 23:59:54 +0000 六眼飞鱼酱① 1540667 at https://www.e-learn.cn