Viewing 15 replies - 1 through 15 (of 27 total)
  • @mj00712 You can use OneSignal in AMP via the amp-web-push component. To do so you can follow the steps in this guide. The WordPress section on that URL refers to another amp plugin, so follow the first steps (for non WordPress publishers). You will need to place the relevant files on the site also, via FTP or file manager.

    Alternatively you can ask the same question on the plugins support forum.Just be sure to mention you are using this amp plugin.

    Thread Starter Muhammad Junaid

    (@mj00712)

    For all AMP pages on your site that you’d like to enable web push notifications, add the following script within your AMP page’s head section. Should I add the code to the header of the website? Do I need to edit the plugin?

    Plugin Author Weston Ruter

    (@westonruter)

    I’ve actually opened a pull request to OneSignal to directly support the AMP plugin: https://github.com/OneSignal/OneSignal-WordPress-Plugin/pull/187

    I suggest chiming in there to push it forward.

    Thread Starter Muhammad Junaid

    (@mj00712)

    Thanks. But can you tell where is head for amp page?

    @mj00712 For the head section you just need to call the amp-web-push component. So for that part the following will work, just add it to the end of your functions.php file.

    add_filter(
            'amp_post_template_data',
            function( $data ) {
                    $data['amp_component_scripts'] = array_merge(
                            $data['amp_component_scripts'],
                            array(
                                    'amp-web-push' => true,
                            )
                    );
                    return $data;
            }
    );

    That will resolve step 2 from the documentation, by adding the required script.

    Thread Starter Muhammad Junaid

    (@mj00712)

    Thanks for the Reply What about the third, fourth and fifth step how can they be resolved. Kindly can you help?

    For step 3 you will need to follow the guide by downloading the listed files.

    If you are using the plugin in transitional mode you can make the other changes to your active WordPress theme files.

    If you are using the plugin in reader mode I would advise copying the required template (html-start.php) from the amp plugin folder (wp-content/plugins/amp/templates) to a folder called amp in your active themes directory and making the changes there. It’s much better as any updates to the amp plugin won’t overwrite the changes you make. In there you’ll find the <head> and <body> tags for your amp URLs.

    Thread Starter Muhammad Junaid

    (@mj00712)

    Do I have to create the amp folder in theme?

    @mj00712 Yes, you will need to create the amp folder.

    Thread Starter Muhammad Junaid

    (@mj00712)

    Now in step 4 where should I add code for AMP pages content? and will it remain there if the plugin is updated?

    You can apply the changes to the html-start.php file within your themes amp folder in the locations specified in the manual. (ie – the <head> location). I assume you also added the correct code to the <body> from step 3.

    You can place the widget code from step 4 in another one of the reader mode templates, such as html-end.php, also from within the amp folder and copied from the plugins template files.

    Thread Starter Muhammad Junaid

    (@mj00712)

    It works I have used the single.php file but now its the placement issue. I want to place the Subscription widget just before the Facebook comments plugin.

    Thread Starter Muhammad Junaid

    (@mj00712)

    Now these errors show up

    @mj00712 If you share your site URL we can take a look.

    Thread Starter Muhammad Junaid

    (@mj00712)

    URL

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘OneSignal Push Notification Intergration’ is closed to new replies.